[Bug] Inline DTD's and XML4J ?

Carl Schei carl at catapultt.com
Sun Jun 6 20:18:27 BST 1999


Hi There,

This is my first posting to XML-Dev. Great mailing list. I have been using the IBM XML4J Parser (v2.0.9) class for just a short while. The client has requested that we inline the DTD's instead of making them external.

I resorted to the following sample code,

        Parser p = new Parser(getDefaultDTDPath(), this, null);
        DTD aDTD = null ;
        try {
            BufferedReader b = new BufferedReader(new FileReader("SampleDTD.dtd")) ;
            aDTD = p.readDTDStream(b) ;
            b.close() ;
        } catch (IOException ex) { }
        aDTD.setName("CustomerDataResponse") ;
        StringWriter aWriter = new StringWriter();
        try {
            aDTD.print(aWriter) ;
        } catch (IOException ex) {}
        System.out.println(aWriter.toString()) ;

Used on the following XML file (with inline DTD),
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CustomerDataResponse [
<!ELEMENT CustomerDataResponse (pass|fail)>
<!ATTLIST CustomerDataResponse accountNumber CDATA #REQUIRED>
<!ELEMENT pass (question*)>
<!ELEMENT question (#PCDATA)>
<!ATTLIST question questionId ID #REQUIRED
                   answers CDATA #IMPLIED>
<!ELEMENT fail (reason)>
<!ELEMENT reason (#PCDATA)>
]>



Produces the results,
<!DOCTYPE CustomerDataResponse [
<!ATTLIST CustomerDataResponse accountNumber CDATA #REQUIRED>
<!ELEMENT pass (question*)>
<!ELEMENT question (#PCDATA)>
<!ATTLIST question questionId ID #REQUIRED
                   answers CDATA #IMPLIED>
<!ELEMENT fail (reason)>
<!ELEMENT reason (#PCDATA)>
]>


Note that there is no line,

<!ELEMENT CustomerDataResponse (pass|fail)>

Which totally invalidates the DTD.

Now the interesting thing is that if I duplicate this line in the original DTD, i.e.,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CustomerDataResponse [
<!ELEMENT CustomerDataResponse (pass|fail)>
<!ELEMENT CustomerDataResponse (pass|fail)>
<!ATTLIST CustomerDataResponse accountNumber CDATA #REQUIRED>
<!ELEMENT pass (question*)>
<!ELEMENT question (#PCDATA)>
<!ATTLIST question questionId ID #REQUIRED
                   answers CDATA #IMPLIED>
<!ELEMENT fail (reason)>
<!ELEMENT reason (#PCDATA)>
]>


It produces the desired results!! Anyone found similiar results? I can't think of anything that I'm doing wrong.

Thanks,

Carl Schei
Catapult Technology, Inc.
(630) 515-3670 phone
carl at catapultt.com
http://www.catapultt.com/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ic.ac.uk/pipermail/xml-dev/attachments/19990606/0386c3c1/attachment.htm


More information about the Xml-dev mailing list