[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Required attribue with a default enumerated attribute valu

  • From: "G. Ken Holman" <gkholman@C...>
  • To: <xml-dev@l...>
  • Date: Thu, 05 Mar 2009 14:28:42 -0500

RE:  Required attribue with a default enumerated attribute valu
At 2009-03-05 19:09 +0000, Graeme Kidd wrote:
> > * Graeme Kidd wrote:
> >>Is it possible to make a required attribute with a default 
> enumerated attribute value.
> >
> > No.
>That's rather annoying is it not?

Perhaps not from the XML specification's perspective.

>You can have enumerated attribute values but can't require the 
>attribute or you can require the attribute but not as a enumerated 
>attribute value.

But I think you are mixing up the instance content from what an 
XML-based application sees in the instance.

>I suppose the main annoyance is coming from my XML Editor that 
>creates the element without the attribute yet says it has created my 
>attribute with it's default value given by the default enumerated 
>attribute value.

Right ... and because it has a default value, a value need not be specified.

At 2009-03-05 18:27 +0000, Graeme Kidd wrote:
>< !ATTLIST element-name attribute-name (en1|en2|en3) "en3">
>This means that this is valid when I dont't want it to be:
>< element-name> < element-name />

But why do you not want the above to be considered valid?

An XML application (say, for example, an XSLT stylesheet) sees no 
difference between what you have above and:

< element-name attribute-name="en3"> < element-name />

Consider the XML information set section 2.2(5):


where it states:

   "An unordered set of attribute information items, one for each
    of the attributes (specified or defaulted from the DTD) of
    this element"

There is *no* distinction between a specified attribute in the 
instance and a defaulted attribute in the DTD.  The stylesheet (and 
other XML applications based on the information set) sees the 
attribute whether or not it has been specified.  And it cannot 
distinguish when it has one if it was specified or defaulted ... it 
just has it.  So your act of including it in the ATTLIST declaration 
was sufficient, and there is no need (from an XML application's 
perspective) to have it there.

I understand from a human perspective you might want to see it there, 
perhaps for the benefit of a reader of the instance, but it doesn't 
have to be there for the benefit of the XML applications acting on 
the instance.

For human legibility issues you might check the editing tool for a 
feature along the lines of "populate specified attributes from 
defaulted attributes".

There are a number of people on the list (myself included) who feel 
that defaulted attributes (or defaulted content of any kind) do not 
have a role in document models ... rather, an application should have 
its own choice as to what the defaults are for unspecified attributes.

I hope this is considered helpful.

. . . . . . . . Ken

XQuery/XSLT training in Prague, CZ 2009-03 http://www.xmlprague.cz
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@C...
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.