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 15:33:28 -0500


David Spreadbury wrote


> Yes, in XML 1.0, it is specified in the DTD as #REQUIRED, which means the
element must explicitly provide a value for this attribute each time it is
used.
>
> Example:
>
> <!ATTLIST SPECIES
> LatinName CDATA #REQUIRED
> ReferenceType CDATA #IMPLIED
> ReferenceNum CDATA #IMPLIED

David,

This applies to specifying an attribute, not to specifying an element value.

In the following snippet, "the Duke" is the element content and "John Wayne"
is the value of the attribute "Name":

<actor name="John Wayne">the Duke</actor>

In a DTD you cannot specify that the actor element have a value, that is,
element content. In other words, you cannot make the parser complain if it
sees:

<actor name="John Wayne"></actor>

You can require that the attribute "name" be specified when the element
"actor" is used. That is what the #REQUIRED means. Note, however, that this
by itself only requires that the attribute be specified, not that it
actually have a meaningful value. So even if you specify that "name" is a
required attribute of an actor element, the parser still will not complain
if it sees:

<actor name="">the Duke</actor>

You can control what the parser will accept as a valid attribute value, to
some extent, but that is not what #REQUIRED does.

So, the answer to Ned's question really is no.
---
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.



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

Previous by Author: Re: XML ELEMENT value required?
Next by Author: Re: XML ELEMENT value required?
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