Hello dear users and developers!
I have a great problem while parsing some XML-Schemas. My task is to
extract the information from WSDL-Files and parse an included schema as
well.
I read about "Using XML Schema", "Caching & Preparsing Grammars" and
some of the threads in the mailing-list. I saw, that some people had
similar problems, but I can't resolve mine.
So, I parse the wsdl-File with wsdl4j and extract the schema-Element
from it.
Then I want to use the Methods of XSModel, which offer all the
possibilities to extract the necessary information.
Because of the line "<s:element ref="s:schema" />" in the schema (in my
example) I have a problem and the following error:
[Error] :-1:-1: src-resolve.4.2: Error resolving component 's:schema'.
It was detected that 's:schema' is in namespace
'http://www.w3.org/2001/XMLSchema', but components from this namespace
are not referenceable from schema document 'file:/C:/MyData/test.wsdl'.
If this is the incorrect namespace, perhaps the prefix of 's:schema'
needs to be changed. If this is the correct namespace, then an
appropriate 'import' tag should be added to 'file:/C:/MyData/test.wsdl'.
I don't want to make some changes in the wsdl-File, because the
validation is not important for me, my task is to analyse the existing
files and not to improve them. The most confusing thing is that the
parser extracts everything what I want from the schema element (i.e. it
runs without to stop), but I see this validation error all the time.
I don't want to validate! I want to extract! What can I do in this case?
Can I turn off the validation feature and get an XSModel anyway? Can I
turn off the reporting of the validation errors?
Can some art of resolver help in this case? Can I say: if s:schema
appears, the "http://www.w3.org/2001/XMLSchema" schould be used? I don'd
understand the feature setEntityResolver... Can anybody give some
samples? Could I use some default resolvers or the resolvers in
resolver.jar? How can I do this?
Please, help me!
Best regards,
Nataliya
Here is some Code for better undestanding:
WSDLFactory factory = WSDLFactory.newInstance();
WSDLReader reader = factory.newWSDLReader();
reader.setFeature("javax.wsdl.verbose", true);
reader.setFeature("javax.wsdl.importDocuments", true);
String urlToWSDLFile = "C:/MyData/test.wsdl";
Definition def = reader.readWSDL(urlToWSDLFile);
Element rootSchemaElement = getSchemaElementFromDefinition(def);
DOMInputSource domInput = new DOMInputSource(rootSchemaElement);
XMLGrammarPreparser xmlGrammarPreparser = new XMLGrammarPreparser();
xmlGrammarPreparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA,null);
XMLGrammarLoader schemaLoader =
xmlGrammarPreparser.getLoader(XMLGrammarDescription.XML_SCHEMA);
try {
Grammar preparseGrammar =
xmlGrammarPreparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA,
domInput);
XSGrammar xsGrammar = (XSGrammar) preparseGrammar;
XSModel xsModel = xsGrammar.toXSModel();
getElementsFromSchema(xsModel);
......................
___________________________________________________________
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]