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 Brian Atkins <br...@agilent.com> on 2003/08/04 23:37:46 UTC
Validation fails with targetNamespace == default namespace?
Help me understand what I am doing wrong. Here's a small example
of two document which, as far as I can tell, conform to the
given schema. One (good.xml) uses a default namespace (no prefix), while
the other (bad.xml) uses an explicit namespace (prefix='ex').
example.xsd
===========
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace='http://www.someone.com/example'
xmlns='http://www.someone.com/example'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-Instance'
xml:lang="en">
<xsd:element name="Root">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="AnElement" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
good.xml - target namespace with prefix 'ex'
============================================
<?xml version="1.0" encoding="UTF-8"?>
<ex:Root xmlns:ex="http://www.someone.com/example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.someone.com/example example.xsd">
<AnElement/>
</ex:Root>
bad.xml - target namespace as default namespace
===============================================
<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns="http://www.someone.com/example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.someone.com/example example.xsd">
<AnElement/>
</Root>
Running both document and schema using SAX with schema and validation
turned on, I get no errors on "good.xml", but get the following on
"bad.xml":
cvc-complex-type.2.4.a: Invalid content starting with element 'AnElement'.
One of '{"":AnElement}' is expected.
Any help would be most welcome.
Thanks
Brian Atkins
--
Brian Atkins brian_atkins@agilent.com (970) 288-2114
Agilent Technologies 4380 Ziegler Road - MS ISP Ft. Collins, CO 80525
---------------------------------------------------------------------
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 fails with targetNamespace == default namespace?
Posted by "K. Venugopal" <k....@sun.com>.
Hi Brain ,
Which version of xerces are using please try using the latest version
and let us know if you are still facing the problem
-venu
Brian Atkins wrote:
> Help me understand what I am doing wrong. Here's a small example
> of two document which, as far as I can tell, conform to the
> given schema. One (good.xml) uses a default namespace (no prefix), while
> the other (bad.xml) uses an explicit namespace (prefix='ex').
>
> example.xsd
> ===========
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema targetNamespace='http://www.someone.com/example'
> xmlns='http://www.someone.com/example'
> xmlns:xsd='http://www.w3.org/2001/XMLSchema'
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-Instance'
> xml:lang="en">
>
> <xsd:element name="Root">
> <xsd:complexType>
> <xsd:sequence>
> <xsd:element name="AnElement" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
> </xsd:element>
> </xsd:schema>
>
> good.xml - target namespace with prefix 'ex'
> ============================================
> <?xml version="1.0" encoding="UTF-8"?>
> <ex:Root xmlns:ex="http://www.someone.com/example"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.someone.com/example example.xsd">
> <AnElement/>
> </ex:Root>
>
> bad.xml - target namespace as default namespace
> ===============================================
> <?xml version="1.0" encoding="UTF-8"?>
> <Root xmlns="http://www.someone.com/example"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.someone.com/example example.xsd">
> <AnElement/>
> </Root>
>
> Running both document and schema using SAX with schema and validation
> turned on, I get no errors on "good.xml", but get the following on
> "bad.xml":
>
> cvc-complex-type.2.4.a: Invalid content starting with element
> 'AnElement'.
> One of '{"":AnElement}' is expected.
>
> Any help would be most welcome.
>
> Thanks
> Brian Atkins
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org