Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Howto validate xml schema?

 
Alan Mc Kernan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, I want to programatically validate xml schema files.. can someone point me in the right direction. I dont want to validate xml files against a schema, but moreso to validate the schema itself.

Cheers
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't that supposed to be the beauty of schemas versus DTDs? If you know how to validate an xml document against a schema, do that to your schema document: validate myschema.xsd against schema http://www.w3.org/2001/XMLSchema.xsd
[ February 13, 2006: Message edited by: Jeff Albertson ]
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a schema to validate a schema, since a schema is an XML?
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeff Albertson:
Isn't that supposed to be the beauty of schemas versus DTDs? If you know how to validate an xml document against a schema, do that to your schema document: validate myschema.xsd against schema http://www.w3.org/2001/XMLSchema.xsd

[ February 13, 2006: Message edited by: Jeff Albertson ]


Hi Jeff,

I think Alan wanted to validate a schema rather than the actual XML data file. But if I'm mistaken, Jeff's way is correct.

Cheers!
 
Alan Mc Kernan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hrm, yeah that makes sense.

But what about sub files that the XSD imports/links to?

Basically Ill have a directory with a tree of XSD's, some have common elements which are contained in their own XSD and then the top level XSD's import those.

So basically I want to programically (or by some automated means) ensure that they are all valid. i.e there may be cases where the command element XSD's are missing.. or not valid for some reason.
 
Alan Mc Kernan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This technique.. semi works. It will validate that the XSD is well formed, but when I remove an import, which is used in the schema, it still passes with no problems.

Anyone any ideas?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic