Validating XML with a DTD

bene
01-11-2002, 08:37 AM
Okay... XML problem.

I wrote a program for my company that creates an XML file of order information, sends it to our "sister" company, where they have a process that interprets it and loads it on their system. If data within the order itself has errors that can not load on their system, then they send me back an XML response with error information so I can display it back to the user and they fix it. Cool up to that point.

Recently, they have been changing the DTD around, which causes the actual format of the XML document to be wrong, not the data. Because of this, their interpretter picks up their error and sends me as the admin an email. This is bad because then the user is orphaned with no idea if their order was okay or not...

Okay, so my question. I am currently using the DOM to generate and interpret XML. I was wondering if anyone out their knows of a way to use the DOM to validate the XML document against a DTD before I bother sending the file. If I can catch the XML format error first, then I can send a message to the user and everyone is happy.

I know if you open the XML file in IE then it spells out DTD errors for you, but can you do it just within the DOM?

Sorry about being long winded... not sure how much background info is necessary. Also, searched for a while, but not finding anything on using the DOM for validation, so any help is HUGELY appreciated...

Thanks in advance.

Bene

Ranger
01-11-2002, 08:58 AM
Why are they changing the DTD? If you wrote the program that generates the XML (in other words specifying the document structure), shouldn't somebody talk to you first before changing anything?

bene
01-11-2002, 09:05 AM
Yes... you would think so. However, that is not always the case. Or, they notify me with a very short window of oppertunity to affect the changes... but yes, I couldn't agree with you more.

bene
01-14-2002, 10:20 AM
Okay... just for anyone that has a similiar problem in the future... I did figure out how to get the Error information out of the DOM Object Model. This was not easy to find... seems like there is not a ton of documentation out there on it, so maybe this will help someone else out.

This sub can be cut up to do whatever you want, but basically this just verifies that the XML file you are looking at is in a valid format when tested against the DTD (cited within the XML document). Either way, I am popping up a message box that explains the error, or tells you it is clean.

Hope this helps...

bene

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum