TechWhirl (TECHWR-L) is a resource for technical writing and technical communications professionals of all experience levels and in all industries to share their experiences and acquire information.
For two decades, technical communicators have turned to TechWhirl to ask and answer questions about the always-changing world of technical communications, such as tools, skills, career paths, methodologies, and emerging industries. The TechWhirl Archives and magazine, created for, by and about technical writers, offer a wealth of knowledge to everyone with an interest in any aspect of technical communications.
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
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!
---
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.