OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] Required attribue with a default enumerated attribute value

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@CraneSoftwrights.com
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]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS