[jdom-interest] bug in SAXBuilder's validator?
lichadexun at yahoo.com
Tue Jan 8 16:55:39 PST 2002
I was using JDOM to play with XML's ID and IDREF
here's the short XML file I used:
---- cut from here ---
<?xml version="1.0" encoding="UTF-8" ?>
<!ELEMENT TicketDoc (#PCDATA | Ticket | List)*>
<!ELEMENT List (#PCDATA)>
<!ATTLIST List ticketID ID #IMPLIED>
<!ELEMENT Ticket (#PCDATA)>
<!ATTLIST Ticket ticketIDRef IDREF #REQUIRED>
Outstanding tickets are <Ticket
---- cut from here ----
Ticket's ticketIDRef attrib should be a "pointer" to
an ID type, which is List's ticketID. So as long as
ticketIDRef's value "T12345" appears within the
document as a value for the ID type, the above xml
should be valid, which is the case with above example.
However, JDOM's SAXBuilder gives a validation error.
If uncommenting the other List instance that comes
before the Ticket element, then the validator is able
to find the <List> element with ID="T12345", and there
is no error.
The error also goes away if moving the <List> element
with ID="T12345" BEFORE the <Ticket> element with
So it seems that either the "pointed-to" ID value
should come before the corresponding "pointer" IDRef
value, or there has to be at least one instance of
(irrelavent) ID value before the same pointer IDRef
for validation to pass.
Here's the code snippet used for parsing:
SAXBuilder b = new SAXBuilder();
Document doc = b.build("...file.xml");
Am i doing something wrong?
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
More information about the jdom-interest