Meaningless Drivel is fun!*
The moose likes XML and Related Technologies and the fly likes xml/dtd Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml/dtd" Watch "xml/dtd" New topic
Author

xml/dtd

nisharma sharma
Greenhorn

Joined: Aug 05, 2003
Posts: 4
Hai,
I am preparing dtd.Can I restrict user to specify a predefined entry for element.
for example..
<male>true</male>
male is a element.
I want, user can only specify either true or false.I know i can do it with XMLschema.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Moving to the XML forum.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Go to http://www.w3schools.com/dtd/dtd_attributes.asp and look the section titled "Enumerated attribute values".


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
cyril vidal
Ranch Hand

Joined: Jul 02, 2003
Posts: 247
With XML Schema, it's very easy, just use the type boolean:
<xs:element name="male" type="xs:boolean"/>
With DTD, as said Lasse, you have to use enumerated attribute values:
<!ATTLIST Element male (true|false) "true">
XML Example:
<Element male="true"/>
<Element male="false"/>
<Element/>
Hope this helps,
Cyril.


SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: xml/dtd