You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Jean-Guillaume LALANNE <je...@coming.fr> on 2001/03/09 15:52:14 UTC
Validation problem : targetNamespace of the imported Schema different from what is declared ....
Hi,
I am using in parallel XMLSpy and xerces1.3.0 and I am confronted to the following problem.
I am managing to validate an xml document in XMLSpy and I don't manage to do so in xerces.
I am wondering if :
- my schemas are not valid and xerces is right and XMLSpy not.
- the opposite.
Here are my schemas :
File : shoppingcartline.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.toto.com/validation/Schemas/toto-shoppingcartline"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline">
<xsd:element name="shoppingcartline">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcartline:pK"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="pK" type="xsd:int" />
</xsd:schema>
File : shoppingcart.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:toto-shoppingcart="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline">
<xsd:import schemaLocation="shoppingcartline.xsd"/>
<xsd:element name="shoppingcart">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcart:pK"/>
<xsd:element ref="toto-shoppingcart:list-shoppingcartline"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="pK" type="xsd:int" />
<xsd:element name="list-shoppingcartline">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcartline:shoppingcartline" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
File : shoppingcart.xml
<?xml version="1.0" encoding="UTF-8"?>
<shoppingcart
xmlns="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation="http://www.toto.com/validation/Schemas/whip-shoppingcart shoppingcart.xsd">
<pK>2</pK>
<list-shoppingcartline>
<toto-shoppingcartline:shoppingcartline>
<toto-shoppingcartline:pK>555</toto-shoppingcartline:pK>
<toto-shoppingcartline:quantity>888</toto-shoppingcartline:quantity>
</toto-shoppingcartline:shoppingcartline>
</list-shoppingcartline>
</shoppingcart>
This previous file is valid for XMLSpy but it is NOT for xerces1.3.0.
I got the following error message :
[error] file:///shoppingcart.xml 6:96 Schema error: imported schema 'shoppingcartline.xsd,shoppingcartline.xsd'
has a different targetNameSpace 'http://www.toto.com/validation/Schemas/toto-shoppingcartline' from what is declared ''..
Where am I wrong ?
Any suggestion is appreciated.
Thanks a lot.
Jean-Guillaume LALANNE
jglalanne@coming.fr
Re: Validation problem : targetNamespace of the imported Schema different from what is declared ....
Posted by Jean-Guillaume LALANNE <je...@coming.fr>.
But about "whip" and "quantity", it is because I trnasform in an exemple for the mailing list my real xsd and xml files and for these 2 tags
I forgot to delete them or to transform them ...
So this is not my problem actually ...
Anyway thanks Paul.
I didn't know about this XMLSpy behavior ...!!!
----- Original Message -----
From: Grégoire Pau
To: xerces-j-dev@xml.apache.org
Sent: Friday, March 09, 2001 5:13 PM
Subject: Re: Validation problem : targetNamespace of the imported Schema different from what is declared ....
Maybe there are some bugs in your file.
XMLSpy often validates file althought they are not correct.
Especially when dealing with more than one schema.
Some comments... :
In your description XML file :
xsi:schemaLocation="http://www.toto.com/validation/Schemas/whip-shoppingcart
should be "toto" and not "whip"
In your description XML file :
The "quantity" element is not defined is the two schemas.
_________________________________________________
Grégoire Pau
Expway
----- Original Message -----
From: Jean-Guillaume LALANNE
To: xerces-j-user@xml.apache.org
Cc: xerces-j-dev@xml.apache.org
Sent: Friday, March 09, 2001 3:52 PM
Subject: Validation problem : targetNamespace of the imported Schema different from what is declared ....
Hi,
I am using in parallel XMLSpy and xerces1.3.0 and I am confronted to the following problem.
I am managing to validate an xml document in XMLSpy and I don't manage to do so in xerces.
I am wondering if :
- my schemas are not valid and xerces is right and XMLSpy not.
- the opposite.
Here are my schemas :
File : shoppingcartline.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.toto.com/validation/Schemas/toto-shoppingcartline"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline">
<xsd:element name="shoppingcartline">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcartline:pK"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="pK" type="xsd:int" />
</xsd:schema>
File : shoppingcart.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:toto-shoppingcart="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline">
<xsd:import schemaLocation="shoppingcartline.xsd"/>
<xsd:element name="shoppingcart">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcart:pK"/>
<xsd:element ref="toto-shoppingcart:list-shoppingcartline"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="pK" type="xsd:int" />
<xsd:element name="list-shoppingcartline">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcartline:shoppingcartline" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
File : shoppingcart.xml
<?xml version="1.0" encoding="UTF-8"?>
<shoppingcart
xmlns="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation="http://www.toto.com/validation/Schemas/whip-shoppingcart shoppingcart.xsd">
<pK>2</pK>
<list-shoppingcartline>
<toto-shoppingcartline:shoppingcartline>
<toto-shoppingcartline:pK>555</toto-shoppingcartline:pK>
<toto-shoppingcartline:quantity>888</toto-shoppingcartline:quantity>
</toto-shoppingcartline:shoppingcartline>
</list-shoppingcartline>
</shoppingcart>
This previous file is valid for XMLSpy but it is NOT for xerces1.3.0.
I got the following error message :
[error] file:///shoppingcart.xml 6:96 Schema error: imported schema 'shoppingcartline.xsd,shoppingcartline.xsd'
has a different targetNameSpace 'http://www.toto.com/validation/Schemas/toto-shoppingcartline' from what is declared ''..
Where am I wrong ?
Any suggestion is appreciated.
Thanks a lot.
Jean-Guillaume LALANNE
jglalanne@coming.fr
Re: Validation problem : targetNamespace of the imported Schema different from what is declared ....
Posted by Grégoire Pau <gp...@acland.fr>.
Maybe there are some bugs in your file.
XMLSpy often validates file althought they are not correct.
Especially when dealing with more than one schema.
Some comments... :
In your description XML file :
xsi:schemaLocation="http://www.toto.com/validation/Schemas/whip-shoppingcart
should be "toto" and not "whip"
In your description XML file :
The "quantity" element is not defined is the two schemas.
_________________________________________________
Grégoire Pau
Expway
----- Original Message -----
From: Jean-Guillaume LALANNE
To: xerces-j-user@xml.apache.org
Cc: xerces-j-dev@xml.apache.org
Sent: Friday, March 09, 2001 3:52 PM
Subject: Validation problem : targetNamespace of the imported Schema different from what is declared ....
Hi,
I am using in parallel XMLSpy and xerces1.3.0 and I am confronted to the following problem.
I am managing to validate an xml document in XMLSpy and I don't manage to do so in xerces.
I am wondering if :
- my schemas are not valid and xerces is right and XMLSpy not.
- the opposite.
Here are my schemas :
File : shoppingcartline.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.toto.com/validation/Schemas/toto-shoppingcartline"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline">
<xsd:element name="shoppingcartline">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcartline:pK"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="pK" type="xsd:int" />
</xsd:schema>
File : shoppingcart.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
targetNamespace="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:toto-shoppingcart="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline">
<xsd:import schemaLocation="shoppingcartline.xsd"/>
<xsd:element name="shoppingcart">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcart:pK"/>
<xsd:element ref="toto-shoppingcart:list-shoppingcartline"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="pK" type="xsd:int" />
<xsd:element name="list-shoppingcartline">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="toto-shoppingcartline:shoppingcartline" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
File : shoppingcart.xml
<?xml version="1.0" encoding="UTF-8"?>
<shoppingcart
xmlns="http://www.toto.com/validation/Schemas/toto-shoppingcart"
xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:schemaLocation="http://www.toto.com/validation/Schemas/whip-shoppingcart shoppingcart.xsd">
<pK>2</pK>
<list-shoppingcartline>
<toto-shoppingcartline:shoppingcartline>
<toto-shoppingcartline:pK>555</toto-shoppingcartline:pK>
<toto-shoppingcartline:quantity>888</toto-shoppingcartline:quantity>
</toto-shoppingcartline:shoppingcartline>
</list-shoppingcartline>
</shoppingcart>
This previous file is valid for XMLSpy but it is NOT for xerces1.3.0.
I got the following error message :
[error] file:///shoppingcart.xml 6:96 Schema error: imported schema 'shoppingcartline.xsd,shoppingcartline.xsd'
has a different targetNameSpace 'http://www.toto.com/validation/Schemas/toto-shoppingcartline' from what is declared ''..
Where am I wrong ?
Any suggestion is appreciated.
Thanks a lot.
Jean-Guillaume LALANNE
jglalanne@coming.fr
Re: Validation problem : targetNamespace of the imported Schema
different from what is declared ....
Posted by Elena Litani <hl...@jtcsv.com>.
Hi, Jean-Guillaume,
> Jean-Guillaume LALANNE wrote:
> - my schemas are not valid and xerces is right and XMLSpy
> not.
I believe Xerces is right.
According to schema specs if there is a namespace attribute is present,
then its value must be identical to the value of the targetNamespace
attribute of imported schema.
If there is no namespace attribute, then imported Schema must have no
targetNamespace attribute.
In your shoppingcartline.xsd you have *targetNamespace* attribute, thus
then importing it you should specify *namespace* attribute on import.
See 6.2.3 (Schema Part 1):
"The normalized value of its namespace [attribute] indicates that the
containing schema document may contain qualified references to schema
components in that namespace (via one or more prefixes declared with
namespace declarations in the normal way). If that attribute is absent,
then the import allows unqualified reference to components with no
target namespace."
Elena
> - the opposite.
>
> Here are my schemas :
>
> File : shoppingcartline.xsd
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema
>
> targetNamespace="http://www.toto.com/validation/Schemas/toto-shoppingcartline"
>
> xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>
> xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline">
>
> <xsd:element name="shoppingcartline">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="toto-shoppingcartline:pK"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> <xsd:element name="pK" type="xsd:int" />
>
> </xsd:schema>
>
> File : shoppingcart.xsd
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema
>
> targetNamespace="http://www.toto.com/validation/Schemas/toto-shoppingcart"
>
> xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
>
> xmlns:toto-shoppingcart="http://www.toto.com/validation/Schemas/toto-shoppingcart"
>
> xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline">
>
> <xsd:import schemaLocation="shoppingcartline.xsd"/>
>
> <xsd:element name="shoppingcart">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="toto-shoppingcart:pK"/>
> <xsd:element ref="toto-shoppingcart:list-shoppingcartline"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> <xsd:element name="pK" type="xsd:int" />
>
> <xsd:element name="list-shoppingcartline">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element ref="toto-shoppingcartline:shoppingcartline"
> minOccurs="0" maxOccurs="unbounded"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
>
> </xsd:schema>
>
>
> File : shoppingcart.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <shoppingcart
>
> xmlns="http://www.toto.com/validation/Schemas/toto-shoppingcart"
>
> xmlns:toto-shoppingcartline="http://www.toto.com/validation/Schemas/toto-shoppingcartline"
> xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
>
> xsi:schemaLocation="http://www.toto.com/validation/Schemas/whip-shoppingcart shoppingcart.xsd">
>
> <pK>2</pK>
> <list-shoppingcartline>
> <toto-shoppingcartline:shoppingcartline>
> <toto-shoppingcartline:pK>555</toto-shoppingcartline:pK>
> <toto-shoppingcartline:quantity>888</toto-shoppingcartline:quantity>
> </toto-shoppingcartline:shoppingcartline>
> </list-shoppingcartline>
> </shoppingcart>
>
> This previous file is valid for XMLSpy but it is NOT for xerces1.3.0.
> I got the following error message :
>
> [error] file:///shoppingcart.xml 6:96 Schema error: imported schema
> 'shoppingcartline.xsd,shoppingcartline.xsd'
> has a different targetNameSpace
> 'http://www.toto.com/validation/Schemas/toto-shoppingcartline' from
> what is declared ''..
>
> Where am I wrong ?
>
>
> Any suggestion is appreciated.
> Thanks a lot.
> Jean-Guillaume LALANNE
> jglalanne@coming.fr
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: Validation problem : targetNamespace of the imported Schema different from what is declared ....
Posted by Ragunath Marudhachalam <rm...@circuitvision.com>.
hi
even i'm having the same problem... i'm also confused whether my code is
right or not... but i have tested the xerces in a standalone application and
in a servlet.... in a standalone application, it works perfect... it throws
me error if the xml document is not according to the schema. but the same
code if is embeded in servlet, it just parses but doesn't throw me error.
I'm also using xmlspy and there it works perfect.... if u want to look at my
code, i will mail u that