aspose file tools*
The moose likes XML and Related Technologies and the fly likes How to restrict Element content ?? 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 "How to restrict Element content ??" Watch "How to restrict Element content ??" New topic
Author

How to restrict Element content ??

Mohan xml
Greenhorn

Joined: Apr 06, 2001
Posts: 3
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
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
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

Joined: Apr 06, 2001
Posts: 3
Dear Bill,
But can i restrict , the length of the attribute in the tag using DTD, if so how ??
Thanx in advance..
mohan
Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
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.
Jane Griscti
Ranch Hand

Joined: Aug 30, 2000
Posts: 3141
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


Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
 
 
subject: How to restrict Element content ??