OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   [Bug] Inline DTD's and XML4J ?

[ Lists Home | Date Index | Thread Index ]
  • From: "Carl Schei" <carl@catapultt.com>
  • To: <xml-dev@ic.ac.uk>
  • Date: Sun, 6 Jun 1999 13:22:50 -0500

 
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@catapultt.com
http://www.catapultt.com/




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS