cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Pope <>
Subject XPath tokenize
Date Mon, 04 Apr 2005 23:17:49 GMT

Is it possible to use the tokenize function in an XSL transformed by 
cocoon?  I've had a little play with something like the following transform:

<xsl:stylesheet version="2.0"

    <xsl:param name="url"/>

    <xsl:variable name="urlTokens" select="fn:tokenize($url, '/')"/>
    <!-- the following line is fine -->
    <xsl:variable name="urlToken1" select="fn:item-at($urlTokens, 1)"/>

    <!-- Something like this line fails with "Unknown error in XPath" -->
    <xsl:value-of select="$urlToken1" />

    <!-- Something like this line fails with an NPE -->
    xsl:value-of select="fn:item-at($urlTokens, 0)" />

Would Saxon work here?

Would JX be my friend by allowing me to call a StringTokenizer?

I've not really used the JX stuff, and not sure what it's advantages are 
over XSL when working directly with an XML backend.

How else do you suggest I do this?

I could pass the parameters is from the sitemap, tokenising there with 
the matcher, but it would mean creating multiple match sections for each 
level.  I might have to do that if there's nothing "neater".

To take a step back, I'm trying to create a trail (breadcrumbs, etc), I 
had look previously for examples, as I seem to recall seeing one, but 
couldn't find anything.

Given a URI like:
or just

I'd like a trail that looks like:

1 -> 2 -> 3
with links to 1.x, 2.x, 3.x
with a link to 1.x

Well, I can sort out all the rendering, I just don't know how to 
tokenize the URI I'm passing in.  Or am I approaching it wrong?

Thanks for your time,
Ben Pope.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message