W3C home > Mailing lists > Public > public-qt-comments@w3.org > August 2002

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

From: Jeni Tennison <jeni@jenitennison.com>
Date: Mon, 19 Aug 2002 17:28:45 +0100
Message-ID: <156615552497.20020819172845@jenitennison.com>
To: public-qt-comments@w3.org


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

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

where the type definition of fooType is:

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

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 match="bar">
  <xsl:apply-templates />

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">

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.


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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:56:43 UTC