Re: XML ELEMENT value required?

Subject: Re: XML ELEMENT value required?
From: "Mark Baker" <listsub -at- analecta -dot- com>
To: "TECHWR-L" <techwr-l -at- lists -dot- raycomm -dot- com>
Date: Fri, 2 Apr 2004 16:12:58 -0500


David Spreadbury wrote:


> Ned's question was:
>
> "... can I force an XML element's value to be required ?"
>
> Not if the value was valid.
>
> The way I understand XML, is if the DTD "requires" an attribute, whether
it is a valid
> attribute or not, there better be an attribute there.

True, but there is a difference between an element and an attribute. Ned did
not ask about attributes, he asked about elements. The term "value of an
element" which is not strict XML terminology, is generally understood to
mean its data content. (If Ned means something else, then he needs to
clarify.) There is no way to require that an element have data content, or
rather to be precise, if an element is declared with a content model of
#PCDATA, that content model can be satisfied by an empty string, and there
is no way to require that it be anything more than an empty string.

Note also that there is a difference between requiring an attribute to exist
and requiring it to have a value. A DTD can do both of these things, but
what #REQUIRED does is require that an attribute exist, not that it have a
value. If you specify an attribute as CDATA #REQUIRED, the CDATA requirement
can be met by an empty string. So, you can specify:

<!element actor #PCDATA>
<!attlist actor name CDATA #REQUIRED>

But you cannot (with a CDATA attribute) make the parser object if it sees:

<actor name=""></actor>

Which is what I believe Ned is asking for.
---
Mark Baker
Analecta Communications
www.analecta.com
+1 613 614 5881




^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ROBOHELP X5 - ALL NEW VERSION!!

Have you tried the latest in Help Authoring from RoboHelp?
Try ROBOHELP X5 for Free - Now with Word 2003 support, Content
Management, Multi-Author support, PDF and XML support and much more!

Download a free trial today: http://www.ehelp.com/techwr-l4

---
You are currently subscribed to techwr-l as:
archiver -at- techwr-l -dot- com
To unsubscribe send a blank email to leave-techwr-l-obscured -at- lists -dot- raycomm -dot- com
Send administrative questions to ejray -at- raycomm -dot- com -dot- Visit
http://www.raycomm.com/techwhirl/ for more resources and info.



Follow-Ups:

References:
RE: XML ELEMENT value required?: From: David Spreadbury

Previous by Author: Re: XML ELEMENT value required?
Next by Author: Re: Can't be a Profit Center? How about Knowledge Center?
Previous by Thread: RE: XML ELEMENT value required?
Next by Thread: Re: XML ELEMENT value required?


What this post helpful? Share it with friends and colleagues:


Sponsored Ads