Re: Are all values stored as strings?

Hi Roger,

> Now, here is an example of an instance of "num":
>
> <num>32</num>
>
> Question: is it correct that num's value (32) is always represented
> as a "string", regardless of how num is declared? That is, are all
> values just strings, with a "datatype label" associated with the
> string?

In XPath 2.0 and XQuery, implementations are free to store the value
of a node as either the lexical form + a type annotation or the typed
value.

The important consequence of this is that if the <num> element is
typed as a numeric type and you have:

  <num>0032</num>

and then do:

  <xsl:value-of select="num/text()" />

then an implementation that stores the typed value will return "32"
whereas an implementation that stores the lexical form + type
annotation will return "0032".

From the looks of it, I think it's likely that most XQuery
implementations will store the typed value while most XSLT 2.0
implementations will store the lexical form + a type annotation.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Monday, 12 May 2003 10:38:36 UTC