xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Wolfgang Hoschek <whoschek AT lbl.gov>
- To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] setInternalDTDSubset bug
- Date: Thu, 7 Apr 2005 10:14:42 -0700
The bug occurs because Crimson is reporting rubbish as the internal subset, breaking roundtrip ability on subsequent setInternalDTDSubset().
I know you worked around similar bugs before, so I'm wondering if that could be worked around as well. It might well be unfixable. Here is a test (running on the latest stable JDK 1.4.2 on MacOSX):
public class DTDBugTest {
public static void main(String[] args) throws Exception {
DocType dtd = new Builder().build("test.xml").getDocType();
System.out.println("done parsing");
dtd.setInternalDTDSubset(dtd.getInternalDTDSubset());
System.out.println("no bug found");
}
}
test.xml:
---------
<?xml version="1.0"?>
<!DOCTYPE doc [
<!ELEMENT doc (#PCDATA|a|b|c)*>
<!ATTLIST doc id ID #REQUIRED>
<!ELEMENT a (#PCDATA|a|b|c)*>
<!ATTLIST a id ID #REQUIRED>
<!ELEMENT b (#PCDATA|a|b|c)*>
<!ATTLIST b id ID #REQUIRED>
<!ELEMENT c (#PCDATA|a|b|c)*>
<!ATTLIST c id ID #REQUIRED >
]>
<doc id="id0"></doc>
[hoschek /Users/hoschek/unix/devel/nux] fire-java nux.xom.tests.DTDBugTestdone parsing
Exception in thread "main" nu.xom.IllegalDataException: Malformed internal DTD subset: Mixed content model for "doc" must end with ")*", not ")".
at nu.xom.Verifier.checkInternalDTDSubset(Unknown Source)
at nu.xom.DocType.setInternalDTDSubset(Unknown Source)
at nux.xom.tests.DTDBugTest.main(DTDBugTest.java:19)
Caused by: org.xml.sax.SAXParseException: Mixed content model for "doc" must end with ")*", not ")".
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3376)
at org.apache.crimson.parser.Parser2.fatal(Parser2.java:3370)
at org.apache.crimson.parser.Parser2.getMixed(Parser2.java:2257)
at org.apache.crimson.parser.Parser2.getMixedOrChildren(Parser2.java:2100)
at org.apache.crimson.parser.Parser2.maybeElementDecl(Parser2.java:2065)
at org.apache.crimson.parser.Parser2.maybeMarkupDecl(Parser2.java:1390)
at org.apache.crimson.parser.Parser2.maybeDoctypeDecl(Parser2.java:1324)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:656)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
... 3 more
On Apr 7, 2005, at 5:16 AM, Elliotte Rusty Harold wrote:
Wolfgang Hoschek wrote:
xom-1.1-CVS with Crimson JDK 1.4 (but not xerces-2.6.2) has a bug when using doc.setInternalDTDSubset(doc. getInternalDTDSubset()) with the document below. Interestingly, the document parses fine when using crimson with new Builder().build(...). I'm wondering if anything could be done about it?
I can't reproduce this one with the following test:
public void testSetInternalDTDSubsetWithCrimson() {
DocType doctype = new DocType("root");
String dtd = " <!ELEMENT doc (#PCDATA|a|b|c)*>\n"
+ " <!ATTLIST doc id ID #REQUIRED>\n"
+ " <!ELEMENT a (#PCDATA|a|b|c)*>\n"
+ " <!ATTLIST a id ID #REQUIRED>\n"
+ " <!ELEMENT b (#PCDATA|a|b|c)*>\n"
+ " <!ATTLIST b id ID #REQUIRED>\n"
+ " <!ELEMENT c (#PCDATA|a|b|c)*>\n"
+ " <!ATTLIST c id ID #REQUIRED >\n";
doctype.setInternalDTDSubset(dtd);
assertEquals(dtd, doctype.getInternalDTDSubset());
}
Given that this is likely a Crimson bug, and that if it is I don't see any obvious way to work around it, I'm inclined not to worry about it too much. If you could figure out a way to write a unit test that exposes it (especially if it doesn't require me to manually hack the Verifier class just to load Crimson there); I could take another look. However, I suspect I should just blame this on Crimson weirdness, and tell people to use Xerces if they encounter it.
--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
-----------------------------------------------------------------------
Wolfgang Hoschek | email: whoschek AT lbl.gov
Distributed Systems Department | phone: (415)-533-7610
Berkeley Laboratory | http://dsd.lbl.gov/~hoschek/
-----------------------------------------------------------------------
-
[XOM-interest] setInternalDTDSubset bug,
Wolfgang Hoschek, 04/06/2005
-
Re: [XOM-interest] setInternalDTDSubset bug,
Elliotte Rusty Harold, 04/07/2005
-
Re: [XOM-interest] setInternalDTDSubset bug,
Wolfgang Hoschek, 04/07/2005
-
Re: [XOM-interest] setInternalDTDSubset bug,
Elliotte Rusty Harold, 04/07/2005
-
Re: [XOM-interest] setInternalDTDSubset bug,
Elliotte Rusty Harold, 04/07/2005
- Re: [XOM-interest] setInternalDTDSubset bug, Wolfgang Hoschek, 04/07/2005
- Re: [XOM-interest] setInternalDTDSubset bug, Wolfgang Hoschek, 04/07/2005
-
Re: [XOM-interest] setInternalDTDSubset bug,
Elliotte Rusty Harold, 04/07/2005
-
Re: [XOM-interest] setInternalDTDSubset bug,
Elliotte Rusty Harold, 04/07/2005
-
Re: [XOM-interest] setInternalDTDSubset bug,
Wolfgang Hoschek, 04/07/2005
-
Re: [XOM-interest] setInternalDTDSubset bug,
Elliotte Rusty Harold, 04/07/2005
Archive powered by MHonArc 2.6.24.