Jump to content
Brunods

validating the XML file with the schema

Recommended Posts

Hello,I'm still trying to get used to XML & XSD (new for me).I've been running some tests and one doubt showed up:I have my XSD file with my schema, and I have my XML file, that MUST follow what my schema says, right?But how can I know when the XML file DOESN'T fit the schema code, this is an error. But how can I catch this?Thanks :)

Share this post


Link to post
Share on other sites

You need to create an application that will validate the XML file against the Schema. Most server side scripting languages provide this ability and if you need it off the web server, there are also desktop applications to do such validation. In any case, validation (today) is not done automatically when the file is parsed.

Share this post


Link to post
Share on other sites
But how can I know when the XML file DOESN'T fit the schema code, this is an error. But how can I catch this?
As robot said,
You need to create an application that will validate the XML file against the Schema. Most server side scripting languages provide this ability...
What robot refers to is called the DOM, or Document Object Model.Standard steps for using XML: (there are other ways, but this is the common one)1) Load it in a DOM parser2) Make the DOM parser validate it3) access the DOM (not the XML) to get informationPHP5, .Net, and Java have very good DOM implementations.However, something tells me that's not really your goal. If you're like most, you're actually trying to validate two files that you just wrote while learning XML and trying to see if they are correct. You noticed that the w3c does not host a validator (why they do not is beyond me). The first site I've found that claims to do this is http://www.xmlvalidation.com/. I cannot vouch for its suitability, as I haven't used it, but I claims to work.//Matt

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...