aspose file tools*
The moose likes XML and Related Technologies and the fly likes XML Validation / XSD with import and namespcaes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Validation / XSD with import and namespcaes" Watch "XML Validation / XSD with import and namespcaes" New topic
Author

XML Validation / XSD with import and namespcaes

Jussi Taimiaho
Ranch Hand

Joined: Mar 01, 2004
Posts: 40
I have an xsd-file, that imports another xsd. For some reason my parser does not validate a simple xml - it does not accept my child-element for some peculiar reason. I just cannot find the reason why... According to my logic my xml is correct, but for some reason it just doesn't accept my tags. I guess there is an issue with namespaces somewhere... Anybody can help at all?

Main XSD:

Imported xsd:

XML:

Error: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Test'. One of '{"RouteSchema":Test}' is expected.

I have also tried with:
<route:Test> -tags. If I leave the <Test> -tag out, it works fine (minOccures). But adding that simple string-tag just fails...
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Why doesn't your main xsd have a targetNamespace?


Without a targetNamespace for the xsd, the xml instance needs to use noNamespaceSchemaLocation for validation to work.

[My Blog] [JavaRanch Journal]
Jussi Taimiaho
Ranch Hand

Joined: Mar 01, 2004
Posts: 40
Jaikiran Pai wrote:Why doesn't your main xsd have a targetNamespace?
Without a targetNamespace for the xsd, the xml instance needs to use noNamespaceSchemaLocation for validation to work.


I triple-checked my namespaces, and got it working finally. Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML Validation / XSD with import and namespcaes