Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8239965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:19:35+00:00 2026-06-07T20:19:35+00:00

I have a huge xsl file but the section where i use tokenize to

  • 0

I have a huge xsl file but the section where i use “tokenize” to parse through a comma separated string is throwing an error. For simplicity purposes I have broke it down to just test the tokenize piece only and cannot seem to make any progress. I keep getting the following error:

Expression expected. tokenize(–>[<–text],’,’)

I tried using some example xsl shared in other posts but never managed to get it to work. I am having a difficult time understanding why my xsl code below is not valid. It seems t be very straightforward but I think I am missing something simple. Any help to get me in the right direction would be much appreciated.

XSL:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/root">
<xsl:for-each select="tokenize([text],',')"/>
<items>
<item>
<xsl:value-of select="."/>
</item>
</items>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

XML:

<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
<root>
<text>Item1, Item2, Item3</text>
</root>

I am expecting an XML output as follows:

<items>
<item>Item1</item>
<item>Item2</item>
<item>Item3</item>
</items>

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:19:38+00:00Added an answer on June 7, 2026 at 8:19 pm

    As stated by DevNull, tokenize() is an XSLT 2.0 function. However, if your processor supports EXSLT, use can use the str:tokenize() function. Otherwise you will need to user recursion to split your comma separated values like thus …

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:strip-space elements="*" />
    
    <xsl:template match="/">
     <items>
       <xsl:apply-templates select="root/text"/>
     </items>
    </xsl:template>
    
    <xsl:template match="text">
     <xsl:call-template name="tokenize"> 
       <xsl:with-param name="csv" select="." /> 
     </xsl:call-template>    
    </xsl:template>
    
    <xsl:template name="tokenize">
     <xsl:param name="csv" />
      <xsl:variable name="first-item" select="normalize-space( 
        substring-before( concat( $csv, ','), ','))" /> 
     <xsl:if test="$first-item">
      <item>
       <xsl:value-of select="$first-item" /> 
      </item>  
      <xsl:call-template name="tokenize"> 
       <xsl:with-param name="csv" select="substring-after($csv,',')" /> 
      </xsl:call-template>    
     </xsl:if>  
    </xsl:template>
    
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lately I have become a huge fan of XSL, XPath and XML, but I've
I have a huge XML file (114 KB/1719 lines; see the error message below
I have a question about xsl. I have 1 huge xsl file (+4000 lines
I have a huge text file and I wanted to write a program which
I have one huge XML document. I have set of XSL representing each node
I have huge text file of such format: aaa bbb 1 aaa ccc 2
I have huge data in a directory tree format like: c:/user/name/class/std/section I to VI
I have a huge xml file that I would like to split up into
I have huge 1 GB log file. As I know, it shows errors in
I'm parsing a huge word file with Test descriptions, and have a problem of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.