VW:XML - XML w/o DTD, how to add a DTDDocument 
Author Message
 VW:XML - XML w/o DTD, how to add a DTDDocument

My application is getting XML inbound that will *not* have a <!DOCTYPE..>.
Before processing it I'd like to preload the XML.XMLParser with one to
validate the XML against.

Alternatively, after having processed the incoming XML into an XMLDocument,
I'd like to validate it against a DTD.  From what I can read of the classes
the only way to do this would be to reconstruct the XML w/ a <!DOCTYPE...>
element.

Better ideas?

--
.tom



Tue, 26 Aug 2003 00:08:09 GMT  
 VW:XML - XML w/o DTD, how to add a DTDDocument
Thomas

Quote:
> My application is getting XML inbound that will *not* have a <!DOCTYPE..>.
> Before processing it I'd like to preload the XML.XMLParser with one to
> validate the XML against.

I believe it will be much easier to scan the XML inbound text document for
the XML prolog and insert the <!DOCTYPE> specifier text into that document
before asking the parser to parse it.  For example if the inbound document
is:

<?xml version="1.0" encoding="UTF-8"?>
<MyDocument>
    .
    .
    .
</MyDocument>

Your code would convert it to (before parsing):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MyDocument SYSTEM "TheCorrectDTD.dtd">
<MyDocument>
    .
    .
    .
</MyDocument>

Where "TheCorrectDTD.dtd" is the name and path of the text file on your
computer containing the correct DTD for the inbound document.

Quote:
> Alternatively, after having processed the incoming XML into an
XMLDocument,
> I'd like to validate it against a DTD.

This is not the conventional design of XML -- so you will either have to
build something.  I have built a couple of "test-framework" engines that
verify that an XML DOM is: 1) valid XML, 2) conforms to a DTD and 3)
contains the correct attribute and value content.  And if I can do it, you
certainly can!

Quote:
> From what I can read of the classes
> the only way to do this would be to reconstruct the XML w/ a <!DOCTYPE...>
> element.

Yes, that was the basic approach for the test-framework engines used to
verify that an XML DOM is 1) valid XML and 2) conforms to a DTD.  To verify
that an XML DOM contains the correct attribute and value content, the
test-framework engine walked the XML DOM tree checking the value of the
nodes.

Hope that helps!

Regards,

Randy



Tue, 26 Aug 2003 11:25:08 GMT  
 VW:XML - XML w/o DTD, how to add a DTDDocument
That does help, but in a transaction processing system it seems wasteful to
keep parsing something that needs parsing only once, the DTD.  Even though
inserting the DOCTYPE thingy in front does the job, it does it at a
per-transaction cost I'd rather avoid.

--
.tom



Tue, 26 Aug 2003 12:20:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using CLOCC xml.lisp to print XML in XML format

2. VWNC XML DTD Handling?

3. DTD for Ruby reference XML

4. XML and dtd validation

5. Literate XML/DTD programming

6. dtd for XML encoding of X3D

7. Problems with XML and DTD usage

8. XML 1.0 DTD parser for SPARK.

9. XML DTD for Python source?

10. XML and DTD checking

11. Creating dialogs from DTD/XML

12. Script to convert DTD to xml schema

 

 
Powered by phpBB® Forum Software