brothercake
10-16-2002, 06:59 PM
here's my DTD
<!DOCTYPE pubinfo [
<!ELEMENT pubinfo (publication)*>
<!ELEMENT publication (title,url?,date?,size?,source?,author?)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT source (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ATTLIST publication cat CDATA #REQUIRED>
<!ATTLIST publication sub CDATA #REQUIRED>
<!ATTLIST publication sba CDATA #REQUIRED>
]>
Most of the children of <publication> are optional, but I want to specify that, for example
<url />
is not allowed - each optional tag-pair must either not be there, or contain data.
The reason I want to do this is to suit the parsing script. Is it bad practise to validate an XML so specifically, for the benefit of the parsing algorithm, or is it okay to do that? - and if so, how do I specify that in the DTD?
<!DOCTYPE pubinfo [
<!ELEMENT pubinfo (publication)*>
<!ELEMENT publication (title,url?,date?,size?,source?,author?)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT source (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ATTLIST publication cat CDATA #REQUIRED>
<!ATTLIST publication sub CDATA #REQUIRED>
<!ATTLIST publication sba CDATA #REQUIRED>
]>
Most of the children of <publication> are optional, but I want to specify that, for example
<url />
is not allowed - each optional tag-pair must either not be there, or contain data.
The reason I want to do this is to suit the parsing script. Is it bad practise to validate an XML so specifically, for the benefit of the parsing algorithm, or is it okay to do that? - and if so, how do I specify that in the DTD?