Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Handling imports in XML schema

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an XSD against which I have to validate XML documents in my application. The schema imports few namespaces in it, which are defined in other XSD documents.

I am using DocumentBuilderFactory to create validating parsers. Now, I can only provide a single schema as an input to the factory, as a result of which, some XMLs are not getting validated (as they contain elements defined in the imported namespaces).

How do I get around this problem? Do I need to perform some XSLT transformation and merge all the schemas together or is there a convenient way out?

Thanks
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Tushar Madhukar:
How do I get around this problem? Do I need to perform some XSLT transformation and merge all the schemas together or is there a convenient way out?



There is no problem in this.
Still you have a single schema , formed by some element definitions from some other schema using XS:import.

While validating the XML that conforms to this schema , you will pass the schema that you have formed using other import.
 
Evil is afoot. But this tiny ad is just an ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic