This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Tokenized values
- To: Adam Van Den Hoven <Adam dot Hoven at bluezone dot net>
- Subject: Re: [xsl] Tokenized values
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Wed, 25 Jul 2001 10:58:03 +0100
- CC: "XSL Mailing List (E-mail)" <xsl-list at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <00BB1956AE40D411B5B60050DA27311F3C62FA@mail1.bluezone.net>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Adam,
> According to the XML Spec there are several tokenized types (IDREFS,
> ENTITIES, NMTOKENS
> http://www.w3.org/TR/2000/WD-xml-2e-20000814#NT-TokenizedType) 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
Language
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
http://www.exslt.org/str/functions/tokenize/str.tokenize.template.xsl
if you like).
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list