xerces-j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Glavassevich <mrgla...@ca.ibm.com>
Subject Re: parsing XML Schema, no validation required, Problems: Error resolving component 's:schema'...
Date Tue, 18 Mar 2008 03:25:57 GMT
Hi Nataliya,

The schema document embedded in your WSDL is missing a required import:

<s:import namespace="http://www.w3.org/2001/XMLSchema"
schemaLocation="http://www.w3.org/2001/XMLSchema.xsd"/>

This isn't just a validation error. The XSModel you've built is missing
components. If you want to resolve this issue you need to add the import to
the document. If you don't want to edit the file on disk you could add it
to the DOM in memory before passing the schema root Element node to the
XMLGrammarPreparser.

The entity resolver gives your application an opportunity to do custom
resolution of schemaLocations (e.g. redirecting to a local copy of
XMLSchema.xsd) on includes/imports/redefines. There's an FAQ [1] on the XML
Catalog resolver with some examples on the Xerces-J website. Note that it
won't be called in this case unless you have an import for the
"http://www.w3.org/2001/XMLSchema" namespace in your schema.

Thanks.

[1] http://xerces.apache.org/xerces2-j/faq-xcatalogs.html

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Nataliya <wassermann_2005@yahoo.de> wrote on 03/17/2008 02:23:32 PM:

> 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: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org


Mime
View raw message