W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2012

Re: What is the type of an attribute with a default or fixed value? Is it always string?

From: Michael Kay <mike@saxonica.com>
Date: Fri, 20 Jul 2012 12:28:50 +0100
Message-ID: <500940F2.5000303@saxonica.com>
To: xmlschema-dev@w3.org

On 20/07/2012 12:19, Costello, Roger L. wrote:
> Hi Folks,
>
> In section 3.2.2 of the Structures specification it has a box showing this:
>
>      XML Representation Summary: attribute Element Information Item
>
>     <attribute
>           default = string
>           fixed = string
>           ...
>
> I interpret that to mean the type of a default or fixed value is always string. Yes?
The type of the @default (or @fixed) attribute in the schema document is 
string, yes (though there are semantic rules that constrain it further). 
But in the corresponding schema component, the type of the {value} 
property of the value constraint is typed, for example as xs:decimal if 
the attribute being declared has type xs:decimal.
>
> Suppose I declare this:
>
>       <attribute name="pi" type="decimal" default="3.14" />
>
> Suppose I use the default value in an XML instance document:
>
>      pi = "3.14"
>
> Since the value is (presumably) a string type, it is nonsensical to perform arithmetic on it in, say, an XSLT program:
>
>       @pi * diameter
No, you are confusing the type of the @default attribute in the schema 
document with the type of the @pi attribute in the instance document.

Michael Kay
Saxonica
Received on Friday, 20 July 2012 11:29:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 20 July 2012 11:29:16 GMT