wood burning stoves 2.0
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml/dtd" Watch "xml/dtd" New topic


nisharma sharma

Joined: Aug 05, 2003
Posts: 4
I am preparing dtd.Can I restrict user to specify a predefined entry for element.
for example..
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"

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

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

Joined: Jan 23, 2002
Posts: 11962
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"/>
Hope this helps,

SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
I agree. Here's the link: http://aspose.com/file-tools
subject: xml/dtd
It's not a secret anymore!