Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to validate an XML schema i.e. Validate an XSD file

 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I need to validate an XML schema, please note I am not talking about validating an XML document against a schema. I would like to validate the XSD and in addition to validating my XSD i would like to make sure that it is a subset of a large schema. Any ideas on how to do this?

thanks.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An XML Schema is an XML-based document and the process to validate an instance is the same as for any other XML-based document. Is there something that you don't understand about XML validation using XML schema?
 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jimmy thanks for your reply.

I'll give you more information on what I am trying to do. I have created a subset of a parent schema i.e. http://www.landxml.org/schema/LandXML-1.2/LandXML-1.2.xsd. My new custom schema is based on this one. What I would like to do is programmatically make sure that all XML files based on my schema pass validation against my schema and the parent schema. And I think if I could somehow validate my manually created schema against the parent one, I will not have to validate XML files against both schemas?

Does this make sense or am I going about this wrong?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you should be getting familiar with the javax.xml.validation package.

You should be able to use it to - for example, - locate all .xml files in a directory and validate versus a schema.

Bill
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ola, your concept of "subset" and "parent" are off a bit. XML Schemas are not object-oriented and there is no concept of "subset" or "parent." During execution, there is only one XML schema and one XML document. The XML schema can be composed of many files using include and import statements, but conceptually there is only one XML Schema.

So, it sounds like you have created a customized XML schema based on the one at landxml.org. Your customized schema must not include any design changes that conflict with the XML schema at landxml.org if you want your XML documents to validate successfully with both XML Schemas. If your design changes conflict with the XML schema at landxml.org, then there is no way to have your XML documents validate successfully with both of them.

You have to analyze the reasons why your have created a customized XML schema and you have to analyze why you need to be able to validate against the landxml.org XML schema.


And I think if I could somehow validate my manually created schema against the parent one, I will not have to validate XML files against both schemas?


Since your XML documents will contain markup that is not defined in the landxml.org XML Schema, you will never be able to validate your document with the landxml.org XML Schema. This is not possible.

XML Schemas are used to define an XML markup language. If you create your own XML Schema with additonal elements and attibutes and/or restructure something defined in a different XML schema, you essentially have created a new markup language.

 
Ola Daniel
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that explanation Jimmy.

I appreciate it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic