[XML-DEV Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
[Bug] Inline DTD's and XML4J ?
- From: "Carl Schei" <carl@c...>
- To: <xml-dev@i...>
- 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 http://www.catapultt.com/
|
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|
Stylus Studio has published XML-DEV in RSS and ATOM formats,
enabling users to easily subcribe to the list from their preferred news reader application.
|
Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website.
they were not included by the author in the initial post. To view the content without the Sponsor Links please
click here.
|
|