Page 1 of 1

DTD question about ATTLIS

Posted: Wed Jan 19, 2005 7:11 am
by rahul1_parekh
Hi,



Sample of a DTD file for an XML.



<!ELEMENT SEGMENT ( SEG1 | SEG2 | SEG3 )>

<!ATTLIST SEGMENT

ACTION (ACTION1 | ACTION2)

TYPE = XYZ

>



Now if I use this dtd, then the attribute “TYPE” of the element “SEGMENT” will have the value “XYZ” for all the possible elements in the XML (i.e SEG1 or SEG2 or SEG3)



Is there any way by which I can check some condition (say for example, whether the “SEGMENT” is “SEG1” or “SEG2” or “SEG3”) and then decide the value of the attribute “TYPE” (something like if .. else) ?



Can anyone please help me ?



Thanks,



Rahul

Posted: Fri Jan 21, 2005 3:35 pm
by george
Hi Rahul,

This kind of constrains cannot be enforced by a DTD. You can do this with Relax NG or with Schematron. oXygen has support for both.

Best Regards,
George