Re: How to validate the field length in DTD

Subject: Re: How to validate the field length in DTD
From: "John E. Simpson" <simpson@xxxxxxxxxxx>
Date: Mon, 24 Jan 2000 15:24:43 -0500
At 02:24 PM 01/24/2000 -0500, Con_Shravan Gunda wrote:
How can i validate the field length in DTD ??

<phonenumber>1234567890</phonenumber>

How can i write a DTD which validates the field length of phonenumber should
be 10.

The answer to this is the same as the answer to your question of last week (about how to validate a numeric datatype): in short, you can't using a plain old DTD. If each digit were its own element, you might be able to do something like:
<!ELEMENT phonenum (digit,digit,digit,digit,digit,
digit,digit,digit,digit,digit) >
which limits it to 10 "digit" child elements. But then (aside from the fact that it will be horrible to create documents like this, at least manually) you're stuck defining *them*, the digit elements themselve -- the best you can do is:
<!ELEMENT digit (#PCDATA) >
which doesn't limit the length at all.


Also like your question of last week, this is very much off-topic for XSL-List. You need to be asking these questions on XML-L. To subscribe to that list, or access its archives, go to:
http://listserv.heanet.ie/xml-l.html


===================================================================
John E. Simpson            |  I spilled spot remover on my dog.
simpson@xxxxxxxxxxx        |  He's gone now.
http://www.flixml.org      |  (Stephen Wright)


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread