Re: [xsl] Tokenized values

Subject: Re: [xsl] Tokenized values
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 25 Jul 2001 10:58:03 +0100
Hi Adam,

> According to the XML Spec there are several tokenized types (IDREFS,
> which
> are valid for attribute values. How would one handle these values in
> XSL? I'm in the middle of building a recursive named template to
> parse out the values but then when I'm done, all I get is a series
> of result trees.
> Is there a reason why XSL doesn't include something like
> <xsl:variable name="values" select="split(@something)" /> 
> <xsl:apply-templates select="$values/text()" />
> It seems that since this functionality handles a common XML
> situation (the HTML class attribute), this should be built in to XSL
> and not an extention.

In the XML Schema world these are known as list data types.
Requirement 4.4 of XPath 2.0 reads:

  4.4 Should Add List Data Type to the Type System of the Expression

  XML Schema allows the definition of simple types derived by list,
  including lists of unions of non-list simple types. XPath 2.0 SHOULD
  support an ordered list of simple-typed values.

So you can probably expect support for handling these kinds of things
with a function come XPath 2.0/XSLT 2.0.

In the short term, there is one function that may help, namely the
id() function, which can take a space-separated string and locate the
elements with those IDs in a document. However you have to jump
through some hoops to use it in any useful way, and it's often easier
to use an extension function (e.g. exsl:tokenize(), saxon:tokenize(),
xalan:tokenize()) or write a recursive template that either acts on
each of the values as it finds them or returns a result tree fragment
that you convert to a node set using a node-set extension function
(you can use the one at
if you like).



Jeni Tennison

 XSL-List info and archive:

Current Thread