OK, different situation then. I thought that you were outputting XML. If you're *accepting* XML, then you must indeed validate it. And the best way to do that is through a schema (XSD file), and NOT a DTD. The XSD file allows you to apply many more controls over the contents of an XML file.
For example: A DTD looks like this:
Code:
<!ELEMENT Root (FillCount, Priority, StartDate)>
<!ELEMENT FillCount (#PCDATA)>
<!ATTLIST FillCount
FillCount NMTOKEN #FIXED "number"
>
<!ELEMENT Priority (#PCDATA)>
<!ELEMENT StartDate (#PCDATA)>
which says you expect a Number for the FillCount element, a String for Priority, and a String for StartDate. According to this, this is a valid document:
Code:
<!DOCTYPE Root SYSTEM "C:\WINNT\Temp\TestDTD.dtd">
<Root>
<FillCount FillCount="number">-3</FillCount>
<Priority>blah blah blah</Priority>
<StartDate>kitty cat</StartDate>
</Root>
Obviously, a negative value for FillCount is wrong, "blah blah blah" is not a valid Priority, and "kitty cat" is not a valid StartDate.
However, using an XSD, you can restrict what people put in the elements to valid values. For an XSD of:
Code:
<xs:schema xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="FillCount">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="9999"/>
<xs:totalDigits value="4"/>
<xs:fractionDigits value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Priority">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Low"/>
<xs:enumeration value="Medium"/>
<xs:enumeration value="High"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="StartDate" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
will prevent them from entering "unusual" values. The FillCount must have values between 0 and 9999 (inclusive), the Priority can only be Low Medium or High, and the StartDate must look like YYYY-MM-DD. All these fields are required (you could make them optional if you wanted), and must be present in this order.
Not to make fun of my customers, but I've seen them send me some amazing (as in dumb) things, and the XSD is my first line of defense against bad data.
Chip H.