While it is not clear at all from this question what you want to do, here is an answer to a part of it:
Is something like this possible using
XSLT/XPath 1.0? I know that 2.0 has a
tokenizing function that would be
perfect for this, but unfortunately
the CMS I am working with does not yet
support 2.0.
Tokenization has been done in XSLT 1.0 for many years. While it is possible to write your own recursive teplate for tokenizing a string, it is good to remember that such a solution already is available in the FXSL library and it is guaranteed to work, is more powerful than the typical tokenization implemented and has no known bugs -- just ready to use.
This is the str-split-to-words
template and here is one typical example of using it:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/common">
<xsl:import href="strSplit-to-Words.xsl"/>
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:variable name="vwordNodes">
<xsl:call-template name="str-split-to-words">
<xsl:with-param name="pStr" select="/"/>
<xsl:with-param name="pDelimiters"
select="', 	 '"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="ext:node-set($vwordNodes)/*"/>
</xsl:template>
<xsl:template match="word">
<xsl:value-of select="concat(position(), ' ', ., ' ')"/>
</xsl:template>
</xsl:stylesheet>
when this transformation is applied on the following XML document:
<t>Sorry, kid, first-borns really are smarter.
First-borns are typically smarter, while
younger siblings get better grades and
are more outgoing, the researchers say</t>
the wanted, correct result is produced:
1 Sorry
2 kid
3 first-borns
4 really
5 are
6 smarter.
7 First-borns
8 are
9 typically
10 smarter
11 while
12 younger
13 siblings
14 get
15 better
16 grades
17 and
18 are
19 more
20 outgoing
21 the
22 researchers
23 say
Do note that the template accepts a parameter named pDelimiters
in which multiple delimiters can be specified.
Update: I finally understood what the OP wants with this problem. Here is my solution, which again uses the str-split-to-words
template for tokenization:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ext="http://exslt.org/common"
>
<xsl:import href="strSplit-to-Words.xsl"/>
<!-- to be applied upon: test-strSplit-to-Words2.xml -->
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:variable name="vCategories">
<xsl:call-template name="str-split-to-words">
<xsl:with-param name="pStr" select=
"/*/select-criteria/Categories"/>
<xsl:with-param name="pDelimiters"
select="'|'"/>
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="*/pages/Page">
<xsl:with-param name="pCategories" select=
"ext:node-set($vCategories)"/>
<xsl:with-param name="pMatchType" select=
"*/select-criteria/MatchType"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="Page">
<xsl:param name="pCategories"/>
<xsl:param name="pMatchType" select="any"/>
<xsl:variable name="vDecoratedCurrent"
select="concat('|', @CategoryIds, '|')"/>
<xsl:variable name="vSelected" select=
"$pCategories/*
[$pMatchType = 'any']
[contains($vDecoratedCurrent,
concat('|', ., '|')
)
][1]
or
not($pCategories/*[not(contains($vDecoratedCurrent,
concat('|', ., '|')
)
)
][1]
)
"/>
<xsl:copy-of select="self::node()[$vSelected]"/>
</xsl:template>
</xsl:stylesheet>
when this transformation is applied on this XML document:
<t>
<select-criteria>
<Categories>851|849</Categories>
<MatchType>any</MatchType>
</select-criteria>
<pages>
<Page CategoryIds="848|849|850|851">Page 1</Page>
<Page CategoryIds="849|850|">Page 2</Page>
<Page CategoryIds="848|850|">Page 3</Page>
<Page CategoryIds="848|849|850|851">Page 4</Page>
<Page CategoryIds="848|850|851">Page 5</Page>
<Page CategoryIds="848|849|850">Page 6</Page>
</pages>
</t>
the wanted, correct result is produced:
<Page CategoryIds="848|849|850|851">Page 1</Page>
<Page CategoryIds="849|850|">Page 2</Page>
<Page CategoryIds="848|849|850|851">Page 4</Page>
<Page CategoryIds="848|850|851">Page 5</Page>
<Page CategoryIds="848|849|850">Page 6</Page>
When in the XML document we specify:
<MatchType>all</MatchType>
we again get the wanted, correct result:
<Page CategoryIds="848|849|850|851">Page 1</Page>
<Page CategoryIds="848|849|850|851">Page 4</Page>