Return-Path: Delivered-To: apmail-xerces-j-dev-archive@www.apache.org Received: (qmail 47011 invoked from network); 18 Mar 2008 12:14:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Mar 2008 12:14:35 -0000 Received: (qmail 63845 invoked by uid 500); 18 Mar 2008 12:14:33 -0000 Delivered-To: apmail-xerces-j-dev-archive@xerces.apache.org Received: (qmail 63817 invoked by uid 500); 18 Mar 2008 12:14:32 -0000 Mailing-List: contact j-dev-help@xerces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: j-dev@xerces.apache.org Delivered-To: mailing list j-dev@xerces.apache.org Delivered-To: moderator for j-dev@xerces.apache.org Received: (qmail 13642 invoked by uid 99); 18 Mar 2008 11:47:13 -0000 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=X-YMail-OSG:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=2ABpsBIGq7Xs6/iEJqXa4QHYEWPTS8eUXExuC6TJ2GItQK65yVpywV6AeWZEJz1+KytWrloqst2titAytvgjAGRjWkbQTBmT3tQB9Yw6RwBdh7IIxEe8hYWTx3owmFInieBMbLq1XM0BGJEbsWm4AmayaBgn6HbrxyS0XL9/SRA=; X-YMail-OSG: Sv.y8CAVM1lw.M2V1o7ydngKa0r1jeLnK.IV9tMBS4cQktEsUXIPPGN.F2nryR5Aj5hYXYzhxFSRIAiWY18hn26msfLyKvrrrduKnUb6U_Mx2crC_tAqhJKPVrw- Date: Tue, 18 Mar 2008 12:46:41 +0100 (CET) From: Nataliya Subject: Re: parsing XML Schema, no validation required, Problems: Error resolving component 's:schema'... To: Michael Glavassevich Cc: j-users@xerces.apache.org, j-dev@xerces.apache.org In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1453333050-1205840801=:86051" Content-Transfer-Encoding: 8bit Message-ID: <938087.86051.qm@web26507.mail.ukl.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org --0-1453333050-1205840801=:86051 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello, thank you very much for the answer! I included the recommended line in my file and saw that it solved the problem. As I already mentioned, I don't want to edit the files manually, so I want to append the necessary information in form of a node. I tried the following: ....Element rootSchemaElement = getSchemaElementFromDefinition(def); Document document = rootSchemaElement.getOwnerDocument(); Element newNode = document.createElement("s:import"); newNode.setAttribute("namespace", "http://www.w3.org/2001/XMLSchema"); newNode.setAttribute("schemaLocation", "http://www.w3.org/2001/XMLSchema.xsd"); schemaElement.insertBefore(newNode, schemaElement.getChildNodes().item(1)); //As alternative to: schemaElement.insertBefore(newNode, schemaElement.getChildNodes().item(1)); //I tried also: schemaElement.appendChild(newNode); I checked (with get-Methods), if the attributes are set and if the NodeName is the proper one, the answer was positive. But if I insert (append) the node and parse the schema I get the following error: [Error] :-1:-1: s4s-elt-invalid-content.1: The content of 'schema' is invalid. Element 's:import' is invalid, misplaced, or occurs too often. I tried to change the number of the item, to which I append, it doesn't help. So the element is likely to be invalid. What am I doing wrong? I think, that something is absent in this node, but I don't know what; maybe it is some character or a symbol, that the tag is closed... I want only to add the following information to the schema: Thanks Best regards, Nataliya Michael Glavassevich schrieb: Hi Nataliya, The schema document embedded in your WSDL is missing a required import: 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 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 "" 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 --------------------------------- Lesen Sie Ihre E-Mails jetzt einfach von unterwegs mit Yahoo! Go. --0-1453333050-1205840801=:86051 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello,

thank you very much for the answer!

I included the recommended line in my file and saw that it solved the problem. As I already mentioned, I don't want to edit the files manually, so I want to append the necessary information in form of a node.
I tried the following:

....Element rootSchemaElement = getSchemaElementFromDefinition(def);
    Document document = rootSchemaElement.getOwnerDocument();
    Element newNode = document.createElement("s:import");
   
    newNode.setAttribute("namespace", "http://www.w3.org/2001/XMLSchema");
    newNode.setAttribute("schemaLocation", "http://www.w3.org/2001/XMLSchema.xsd");
   
   schemaElement.insertBefore(newNode, schemaElement.getChildNodes().item(1));
 
//As alternative  to: schemaElement.insertBefore(newNode, schemaElement.getChildNodes().item(1));
//I tried also: schemaElement.appendChild(newNode);

I checked (with get-Methods), if the attributes are set and if the NodeName is the proper one, the answer was positive. But if I insert (append) the node and parse the schema I get the following error:

[Error] :-1:-1: s4s-elt-invalid-content.1: The content of 'schema' is invalid.  Element 's:import' is invalid, misplaced, or occurs too often.

I tried to change the number of the item, to which I append, it doesn't help. So the element is likely to be invalid.
   
What am I doing wrong? I think, that something is absent in this node, but I don't know what; maybe it is some character or a symbol, that the tag is closed...

I want only to add the following information to the schema: <s:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd"/>

Thanks

Best regards,
Nataliya

Michael Glavassevich schrieb:
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




Lesen Sie Ihre E-Mails jetzt einfach von unterwegs mit Yahoo! Go. --0-1453333050-1205840801=:86051--