File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes tokenize function in XSL Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "tokenize function in XSL" Watch "tokenize function in XSL" New topic
Author

tokenize function in XSL

D Preethi
Ranch Hand

Joined: May 24, 2008
Posts: 68
Hi All,

I am trying to use the tokenize function in XSL to separate a string with ':' characters. However, I am getting a parse error for tokenize method when I use it. Could you please tell me where I am going wrong? This is the code -

<xsl:template name="testList">
<xsl:param name="string" />
<xsl:if test="$string and string-length($string) > 0">
<xsl:for-each select="tokenize($string,':')">
<xsl:choose>
<xsl:when test="position()=1">
<FirstName>
<xsl:value-of select="." />
</FirstName>
</xsl:when>
<xsl:when test="position()=2">
<MiddleName>
<xsl:value-of select="." />
</<MiddleName>
</xsl:when>
<xsl:when test="position()=3">
<LastName>
<xsl:value-of select="." />
</LastName>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:if>
</xsl:template>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16487
    
    2

The tokenize function is part of XSLT 2.0. It's quite likely that you aren't using a transformer which supports XSLT 2.0.

Did you find out about this function from an online tutorial? There is at least one online tutorial (w3schools) which doesn't bother to tell you which functions are only in XSLT 2.0. I always recommend people to not use that one.
D Preethi
Ranch Hand

Joined: May 24, 2008
Posts: 68
Yes Paul. I just discovered that. I was using XSL 1.0 , not 2.0 and w3schools is what I was referring to. So, couldn't make that out. Thanks for your reply. May be we should look at websites which give these details before using the functions.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: tokenize function in XSL
 
Similar Threads
xsl:if and XPath
Help on XSL XPath
XSLT differences Java 1.4.2 to Java 1.6 ?
Handling Nested tables in xsl:fo for saving a document in RTF
where am i going wrong in my xsl transformation