You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by footh <fo...@yahoo.com> on 2007/03/17 00:52:27 UTC

XMLGrammarPreparser causing error in schema import statement without schemaLocation

Take this wsdl:

http://www.nws.noaa.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php?wsdl

Notice in the schema section there are two import
statements with namespace attributes, but no
schemaLocation attributes.  This is perfectly legal
per the XML Schema spec.

However, when using the XMLGrammarPreparser to
preparse the schema, the following error is generated
twice (once for each import):

schema_reference.4: Failed to read schema document
'null', because 1) could not find the document; 2) the
document could not be read; 3) the root element of the
document is not <xsd:schema>.

Presumably, the code is looking for the schemaLocation
attribute, not finding it and instead trying to find
'null'.  I'm thinking this could be a bug, but I may
be doing something wrong.  Can anyone offer any input
or suggestions?

Thanks,

JBF



 
____________________________________________________________________________________
Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/

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


Re: XMLGrammarPreparser causing error in schema import statement without schemaLocation

Posted by footh <fo...@yahoo.com>.
You were right, the message was simply a warning.  The
error handler used was adding every message to the
error list.

I am using a library that validates a WSDL and it was
stopping at that point.  Now, I will ignore warnings
from the grammar parser.

Thanks for your help.

--- Michael Glavassevich <mr...@ca.ibm.com> wrote:

> footh <fo...@yahoo.com> wrote on 03/17/2007 02:44:45
> AM:
> 
> > Thanks for your response.
> > 
> > The messages appear from calling the passed error
> > handler's getErrorMessages() method so I'm
> assuming
> > they're errors.
> 
> Sounds like your error handler may be swallowing the
> severity. I think if 
> you trace this back to the method the parser invoked
> you'll find that it's 
> a warning.
> 
> > I think you are misunderstanding my first message.
> >
> > An example of one of the import tags in the WSDL
> is this:
> > 
> > <xsd:import
> >
>
namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
> 
> I understood it. I'm not disagreeing that this is
> legal.
> 
> > Notice that there is NO schemaLocation attribute. 
> > This is perfectly legal per the XML Schema specs
> (the
> > schemaLocation attribute is rated #IMPLIED, iow
> > optional, see
> http://www.w3.org/2001/XMLSchema.dtd). 
> > In other words, the code shouldn't even bother
> trying
> > to look for anything.  Instead, it tries to look
> for
> > 'null'.
> 
> It's not looking for 'null'. This ends up in the
> formatted message because 
> the replacement parameter for the schema location is
> missing.
> 
> > Basically, it's probably something as simple as
> adding
> > something like this to the code:
> > 
> > if schemaLocation not equal null
> > then resolve the import (whatever the code does
> now)
> > else
> > do nothing
> 
> Schema processors have a lot more freedom than that.
> You should read: 
> http://www.w3.org/TR/xmlschema-1/#schema_reference.
> Xerces reports the 
> warning to inform the user that it attempted to
> locate a schema document 
> but didn't find one. Among other things, this helps
> diagnose issues with 
> lax wildcards since an import which does not resolve
> can affect the 
> validity of instances.
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail:
> j-users-help@xerces.apache.org
> 
> 



 
____________________________________________________________________________________
The fish are biting. 
Get more visitors on your site using Yahoo! Search Marketing.
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php

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


Re: XMLGrammarPreparser causing error in schema import statement without schemaLocation

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
footh <fo...@yahoo.com> wrote on 03/17/2007 02:44:45 AM:

> Thanks for your response.
> 
> The messages appear from calling the passed error
> handler's getErrorMessages() method so I'm assuming
> they're errors.

Sounds like your error handler may be swallowing the severity. I think if 
you trace this back to the method the parser invoked you'll find that it's 
a warning.

> I think you are misunderstanding my first message.
>
> An example of one of the import tags in the WSDL is this:
> 
> <xsd:import
> namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

I understood it. I'm not disagreeing that this is legal.

> Notice that there is NO schemaLocation attribute. 
> This is perfectly legal per the XML Schema specs (the
> schemaLocation attribute is rated #IMPLIED, iow
> optional, see http://www.w3.org/2001/XMLSchema.dtd). 
> In other words, the code shouldn't even bother trying
> to look for anything.  Instead, it tries to look for
> 'null'.

It's not looking for 'null'. This ends up in the formatted message because 
the replacement parameter for the schema location is missing.

> Basically, it's probably something as simple as adding
> something like this to the code:
> 
> if schemaLocation not equal null
> then resolve the import (whatever the code does now)
> else
> do nothing

Schema processors have a lot more freedom than that. You should read: 
http://www.w3.org/TR/xmlschema-1/#schema_reference. Xerces reports the 
warning to inform the user that it attempted to locate a schema document 
but didn't find one. Among other things, this helps diagnose issues with 
lax wildcards since an import which does not resolve can affect the 
validity of instances.

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

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


Re: XMLGrammarPreparser causing error in schema import statement without schemaLocation

Posted by footh <fo...@yahoo.com>.
Thanks for your response.

The messages appear from calling the passed error
handler's getErrorMessages() method so I'm assuming
they're errors.

I think you are misunderstanding my first message.  An
example of one of the import tags in the WSDL is this:

<xsd:import
namespace="http://schemas.xmlsoap.org/soap/encoding/"/>

Notice that there is NO schemaLocation attribute. 
This is perfectly legal per the XML Schema specs (the
schemaLocation attribute is rated #IMPLIED, iow
optional, see http://www.w3.org/2001/XMLSchema.dtd). 
In other words, the code shouldn't even bother trying
to look for anything.  Instead, it tries to look for
'null'.

Basically, it's probably something as simple as adding
something like this to the code:

if schemaLocation not equal null
then resolve the import (whatever the code does now)
else
do nothing

--- Michael Glavassevich <mr...@ca.ibm.com> wrote:

> footh <fo...@yahoo.com> wrote on 03/16/2007 07:52:27
> PM:
> 
> > Take this wsdl:
> > 
> >
>
http://www.nws.noaa.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php?wsdl
> > 
> > Notice in the schema section there are two import
> > statements with namespace attributes, but no
> > schemaLocation attributes.  This is perfectly
> legal
> > per the XML Schema spec.
> > 
> > However, when using the XMLGrammarPreparser to
> > preparse the schema, the following error is
> generated
> > twice (once for each import):
> > 
> > schema_reference.4: Failed to read schema document
> > 'null', because 1) could not find the document; 2)
> the
> > document could not be read; 3) the root element of
> the
> > document is not <xsd:schema>.
> 
> Are you sure you're not just getting a warning
> message? Xerces will report 
> one if it cannot locate [1] a schema document for an
> import after:
> 
> 1) querying its local cache; then
> 2) querying the grammar pool if one was registered;
> then
> 3) querying the entity resolver if one was
> registered; then
> 4) dereferencing the schema location hint if one was
> provided.
> 
> If no schema document is found after all these
> steps, it's *not* an error.
> 
> > Presumably, the code is looking for the
> schemaLocation
> > attribute, not finding it and instead trying to
> find
> > 'null'.  I'm thinking this could be a bug, but I
> may
> > be doing something wrong.  Can anyone offer any
> input
> > or suggestions?
> 
> The message just isn't very informative. This isn't
> a bug, but it 
> certainly could be improved.
> 
> If you want these imports to resolve you should
> register an entity 
> resolver which locates a schema document based on
> the target namespace 
> (and possibly other information provided in the
> XMLSchemaDescription).
> 
> > Thanks,
> > 
> > JBF
> > 
> > 
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail:
> j-users-help@xerces.apache.org
> 
> [1]
> http://www.w3.org/TR/xmlschema-1/#schema_reference
> 
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail:
> j-users-help@xerces.apache.org
> 
> 



 
____________________________________________________________________________________
We won't tell. Get more on shows you hate to love 
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265 

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


Re: XMLGrammarPreparser causing error in schema import statement without schemaLocation

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
footh <fo...@yahoo.com> wrote on 03/16/2007 07:52:27 PM:

> Take this wsdl:
> 
> http://www.nws.noaa.gov/forecasts/xml/SOAP_server/ndfdXMLserver.php?wsdl
> 
> Notice in the schema section there are two import
> statements with namespace attributes, but no
> schemaLocation attributes.  This is perfectly legal
> per the XML Schema spec.
> 
> However, when using the XMLGrammarPreparser to
> preparse the schema, the following error is generated
> twice (once for each import):
> 
> schema_reference.4: Failed to read schema document
> 'null', because 1) could not find the document; 2) the
> document could not be read; 3) the root element of the
> document is not <xsd:schema>.

Are you sure you're not just getting a warning message? Xerces will report 
one if it cannot locate [1] a schema document for an import after:

1) querying its local cache; then
2) querying the grammar pool if one was registered; then
3) querying the entity resolver if one was registered; then
4) dereferencing the schema location hint if one was provided.

If no schema document is found after all these steps, it's *not* an error.

> Presumably, the code is looking for the schemaLocation
> attribute, not finding it and instead trying to find
> 'null'.  I'm thinking this could be a bug, but I may
> be doing something wrong.  Can anyone offer any input
> or suggestions?

The message just isn't very informative. This isn't a bug, but it 
certainly could be improved.

If you want these imports to resolve you should register an entity 
resolver which locates a schema document based on the target namespace 
(and possibly other information provided in the XMLSchemaDescription).

> Thanks,
> 
> JBF
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

[1] http://www.w3.org/TR/xmlschema-1/#schema_reference

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


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