Invoking static Java method from XSLT stylesheet

Post Reply
gweinstock
Posts: 15
Joined: Tue Jul 05, 2005 11:05 am

Invoking static Java method from XSLT stylesheet

Post by gweinstock »

Hi,
We need to URL encode an item in our xsl style sheet used with the Texis search appliance. I have heard that

"If your XSLT processor is Java based, it probably has a namespace reserved for invoking static methods in arbitrary classes in your classpath, and this would
work:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:url="http://whatever/java/java.net.URLEncoder"
exclude-result-prefixes="url">"

Is there a namespace I can use in our custom XSL in order to call the java.net.URLEncoder from the XSLT? I tried a few things, such as

xmlns:java="java"
.
.
.
<xsl:value-of select="java:net.URLEncoder.encode(.)"/>

but to no avail.

Any help would be greatly appreciated.

Thank you,

Gabriel Weinstock
User avatar
John
Site Admin
Posts: 2622
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Invoking static Java method from XSLT stylesheet

Post by John »

It is not a Java based processor. What are you trying to encode? The variables which should need to be should already be URL encoded.
John Turnbull
Thunderstone Software
gweinstock
Posts: 15
Joined: Tue Jul 05, 2005 11:05 am

Invoking static Java method from XSLT stylesheet

Post by gweinstock »

Hi,
We need to URL encode an item in our xsl style sheet used with the Texis search appliance. I have heard that

"If your XSLT processor is Java based, it probably has a namespace reserved for invoking static methods in arbitrary classes in your classpath, and this would
work:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:url="http://whatever/java/java.net.URLEncoder"
exclude-result-prefixes="url">"

Is there a namespace I can use in our custom XSL in order to call the java.net.URLEncoder from the XSLT? I tried a few things, such as

xmlns:java="java"
.
.
.
<xsl:value-of select="java:net.URLEncoder.encode(.)"/>

but to no avail.

Any help would be greatly appreciated.

Thank you,

Gabriel Weinstock
gweinstock
Posts: 15
Joined: Tue Jul 05, 2005 11:05 am

Invoking static Java method from XSLT stylesheet

Post by gweinstock »

we're trying to encode the query string, and append it back on to the results URL.

However, within the XML, the query string appears to be unencoded.

Gabe
User avatar
jason112
Site Admin
Posts: 347
Joined: Tue Oct 26, 2004 5:35 pm

Invoking static Java method from XSLT stylesheet

Post by jason112 »

It's possible to extract the encoded query from a URL in another field. This essentially grabs the text
between "query=" and the next &.

<xsl:value-of select="substring-before(substring-after(UrlSimilar,'query='),'&')"/>
Post Reply