• Post Reply Bookmark Topic Watch Topic
  • New Topic

XML Validation / XSD with import and namespcaes

 
Jussi Taimiaho
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jussi Taimiaho
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!