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

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

From: Costello, Roger L. <costello@mitre.org>
Date: Fri, 20 Jul 2012 11:19:04 +0000
To: "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-ID: <B5FEE00B53CF054AA8439027E8FE17751923114A@IMCMBX04.MITRE.ORG>
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?

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

And one should expect an error to be thrown. Yes?

Now, suppose I don't use the default value:

    pi = "3.14159"

Since the declared type of pi is decimal, I can perform arithmetic on it:

     @pi * diameter

Yes?

Recap: sometimes pi is a string (and I can't do arithmetic on it) and sometime pi is a decimal (and I can do arithmetic on it). Yes?

/Roger
 
Received on Friday, 20 July 2012 11:19:32 GMT

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