Issue-0079: String-value vs. string-value of the typed-value

Hi,

I feel strongly that it would be a mistake to state that the
string-value() of an element (or attribute) is the string value of its
typed-value().

First, consider what happens when an element has mixed content, for
example the string-value() of the element 'foo' in:

  <foo xsi:type="fooType">
    blah <bar>blah</bar> blah
  </foo>

where the type definition of fooType is:

<xs:complexType name="fooType" mixed="true">
  <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="bar" />
  </xs:choice>
</xs:complexType>

This type definition has complex content, therefore attempting to
access the typed-value() of this element will cause an error. If
accessing the string-value() also caused an error, this would make it
very tedious to do the otherwise very simple and common-place
operation of pulling out the text within the foo element.

I think it would be confusing if mixed-content elements or complex
content elements were made an exception to a general rule.

Also, for elements with a simple type, I think it will be confusing
for XSLT users to find that getting the string value of the element
using xsl:value-of will give a different result from apply templates
to the text node held by the element. XSLT authors are used to:

<xsl:template match="bar">
  <xsl:value-of select="." />
</xsl:template>

and:

<xsl:template match="bar">
  <xsl:apply-templates />
</xsl:template>

being the same when bar only holds text.

In addition, I'll note that even when there is a small gap between the
actual text in the source document and the text you can get hold of in
a transformation, people get confused. They wonder why they can't copy
over entity references from the source to the result, for example.
When people get the value of:

  <value xsi:type="xs:double">32</value>

they expect to get the string "32", not the string "3.2E1", because
it's "32" in the source.

Yet another objection is the problem of what to do when you can't get
a string version of a value. What would the string value of this
element be, were the string value defined as the string value of the
typed value:

  <foo xmlns:bar="http://www.example.com/" xsi:type="xs:QName">
    bar:baz
  </foo>

Finally, just on a philosophical/political level, I think it's
important to balance the view of those who think of XML as serialised
data (where what's important is the typed value of a node) and those
who think of XML as marked up text (where what's important is the
content of node in the physical document). I think that equating the
string value to the string value of the typed value places an emphasis
on the data-oriented view of XML; retaining the distinction between
the two is much more balanced.

Cheers,

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

Received on Monday, 19 August 2002 12:28:47 UTC