Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xml/dtd

 
nisharma sharma
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the XML forum.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go to http://www.w3schools.com/dtd/dtd_attributes.asp and look the section titled "Enumerated attribute values".
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic