You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ben Pope <be...@gmail.com> on 2005/04/05 01:17:49 UTC

XPath tokenize

Hi,

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"
       xmlns:fn="http://www.w3.org/2004/10/xpath-functions"
       xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
       xmlns:cinclude="http://apache.org/cocoon/include/1.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:
http://www.host.com/1/2/3.x
or just
http://www.host.com/1.x

I'd like a trail that looks like:

1 -> 2 -> 3
with links to 1.x, 2.x, 3.x
or
1
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: XPath tokenize

Posted by Ben Pope <be...@gmail.com>.
Hi Geert,

Thankyou for your response, I would have likely swapped out the .jar 
file and got stuck!  This method looks more "preferred", so I shall try 
that later.  Hopefully it'll get me up and running.

Thanks,
Ben.

Geert Josten wrote:
> Hi Ben,
> 
> You will need a XSL parser that supports XSL 2.0. Saxon should do the 
> trick.
> 
> Look for Saxon in the example cocoon.xconf and you will find a component 
> definition for saxon with role="....XSLTProcessor/saxon". Next is to 
> define a map:transform (in one of the sitemaps) that specifies a 
> <xslt-processor-role>saxon</xslt-processor-role> as parameter. I 
> wouldn't be surprised if the example (root) sitemap.xmap contains an 
> example for the saxon transformer as well..
> 
> I'll leave the JX questions for others...
> 
> Cheers,
> Geert
> 
> Ben Pope wrote:
> 
>> Hi,
>>
>> 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"
>>
>> Would Saxon work here?
> 
> 
> <snip>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: XPath tokenize

Posted by Geert Josten <Ge...@daidalos.nl>.
Hi Ben,

You will need a XSL parser that supports XSL 2.0. Saxon should do the trick.

Look for Saxon in the example cocoon.xconf and you will find a component definition for saxon with 
role="....XSLTProcessor/saxon". Next is to define a map:transform (in one of the sitemaps) that 
specifies a <xslt-processor-role>saxon</xslt-processor-role> as parameter. I wouldn't be surprised 
if the example (root) sitemap.xmap contains an example for the saxon transformer as well..

I'll leave the JX questions for others...

Cheers,
Geert

Ben Pope wrote:
> Hi,
> 
> 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"
> 
> Would Saxon work here?

<snip>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org