[jdom-interest] bug in SAXBuilder's validator?

ya hu lichadexun at yahoo.com
Tue Jan 8 16:55:39 PST 2002


I was using JDOM to play with XML's ID and IDREF
types.
here's the short XML file I used:
---- cut from here ---
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE TicketDoc
[
<!ELEMENT TicketDoc (#PCDATA | Ticket | List)*>
<!ELEMENT List (#PCDATA)>
<!ATTLIST List ticketID ID #IMPLIED>
<!ELEMENT Ticket (#PCDATA)>
<!ATTLIST Ticket ticketIDRef IDREF #REQUIRED>
]>
<TicketDoc>
<!--List ticketID="T12346"/-->
Outstanding tickets are <Ticket
ticketIDRef="T12345">Tabcd</Ticket>
<List ticketID="T12345"/>
</TicketDoc>
---- 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
IDRef="T12345".

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();
b.setValidation(true);
Document doc = b.build("...file.xml");

Am i doing something wrong?

Thanks,

LMY

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/



More information about the jdom-interest mailing list