This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to restrict Element content ??  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all friends,
I would like to know can we, restrict content(i mean length,values etc....) of an XML element using XML DTD's. Also how to restrict the length of an ATTRIBUTE.
for EX:
<?xml version="1.0" encoding="UTF-8"?>
<TEST>
<JAVARANCH>XML</JAVARANCH>
<TYPE desc='xml'>FORUM</TYPE>
</TEST>
I want a DTD to validate the above xml as
1) element JAVARANCH should contain only XML as value.
2) the attribut desc , should contain value with only 3 chars maximum.
Thanx in advance
bye
mohan
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand your question correctly, you can't use a DTD for this. Various projects are experimenting with "XML Schema" - a sort of DTD replacement that can impose restrictions on XML content.
www.w3.org is a good place to start.
Bill
------------------
author of:
 
Mohan xml
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Bill,
But can i restrict , the length of the attribute in the tag using DTD, if so how ??
Thanx in advance..
mohan
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know you can specify a value for an elemen and make it "final" by desginating the value "fixed". I don't know if you can restrict the length of an attribute value. Bill's link was comprehensive and in depth. Excellent site! Thanks Bill.
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan,
Please read the JavaRanch Name Policy and re-register using a name that complies with the rules.
Thanks for your cooperation.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
 
I will suppress my every urge. But not this shameless plug:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!