Validation fails with targetNamespace == default namespace? 2003-08-04 - By Brian Atkins
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@(protected) (970) 288-2114 Agilent Technologies 4380 Ziegler Road - MS ISP Ft. Collins, CO 80525
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|