Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTD element default value

Status
Not open for further replies.

lonelydragon

Programmer
Aug 5, 2004
75
US
hello, can you give me a hand?
i am now writing a DTD file. andi need to define the legal value for an element. but i have no idea to do that? hope you can give me some help. thank you in advance.
 
DTD's not my strong point, but I don't think you can do this with them. You can, however, do it with XML Schema's.
 
ok. thank you for your advice. i will try Schema. hope it work. thank you.
 
For XML Schema tutorial, check out:


To do a restriction on element values you would do the following:

<xs:element name="car">

<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:simpleType>

</xs:element>

or

<xs:element name="car" type="carType"/>

<xs:simpleType name="carType">
<xs:restriction base="xs:string">
<xs:enumeration value="Audi"/>
<xs:enumeration value="Golf"/>
<xs:enumeration value="BMW"/>
</xs:restriction>
</xs:simpleType>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top