Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xml-dev] Required attribue with a default enumerated attribute

From: "G. Ken Holman" <gkholman@----------------.--->
To: <xml-dev@-----.---.--->
Date: 3/5/2009 7:30:00 PM
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):

   http://www.w3.org/TR/2004/REC-xml-infoset-20040204/#infoitem.element

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


_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@l...
subscribe: xml-dev-subscribe@l...
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent