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

  • Home
  • SEARCH
  • 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 6334275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:37:45+00:00 2026-05-24T18:37:45+00:00

In my XSLT, I have used tokens to split substrings on a single delimiter

  • 0

In my XSLT, I have used tokens to split substrings on a single delimiter (,) however how do I place a unique text to mark each substring? Thank you.

Example, XML document:

<list>1,4,7,9</list>

Desired output:

<w>1</w>
<x>4</x>
<y>7</y>
<z>9</z>
  • 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-05-24T18:37:45+00:00Added an answer on May 24, 2026 at 6:37 pm

    This XSLT 1.0 solution works for your example.

    It recursively splits your input at a delimiter character and assigns individual parts to elements named according to a list you also supply as a parameter.

    When either individual input parts or element names run out (whatever happens first), recursion stops.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:template match="list">
        <xsl:call-template name="split">
          <xsl:with-param name="input" select="." />
          <xsl:with-param name="elems" select="'w,x,y,z'" />
          <xsl:with-param name="delim" select="','" />
        </xsl:call-template>
      </xsl:template>
    
      <xsl:template name="split">
        <xsl:param name="input" select="''" />
        <xsl:param name="elems" select="''" />
        <xsl:param name="delim" select="','" />
    
        <xsl:if test="$elems != '' and $input != '' and $delim != ''">
          <xsl:variable name="curr-part" select="substring-before( concat($input, $delim), $delim)" />
          <xsl:variable name="curr-elem" select="substring-before( concat($elems, $delim), $delim)" />
          <xsl:element name="{$curr-elem}">
            <xsl:value-of select="$curr-part" />
          </xsl:element>
          <xsl:call-template name="split">
            <xsl:with-param name="input" select="substring-after($input, concat($curr-part, $delim))" />
            <xsl:with-param name="elems" select="substring-after($elems, concat($curr-elem, $delim))" />
            <xsl:with-param name="delim" select="$delim" />
          </xsl:call-template>
        </xsl:if>
      </xsl:template>
    
    </xsl:stylesheet>
    

    This template produces, with your input of <list>1,4,7,9</list>:

    <w>1</w><x>4</x><y>7</y><z>9</z>
    

    Note that the sample output is lacking a document element and therefore is not a valid XML document.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some XSLT which is used to select text which has a particular
We have a framework based in C# + XSLT + javascript, that is used
I have used XSLT for a number of years but have never come across
Okay, so I have never used XSLT before, and I saw a couple of
I have a XSLT which will split large xml file into multiple xml file
I have never really used XSLT before and am looking for some advice. I
For some reason, YQL's XSLT table can't parse my stylesheet. I have used the
I have an XSLT file that is used to write to my Web.Config as
we have XSLT to transform XML into HTML in XHTML 1.0 Strict in XSLT
I have this XSLT 2.0: <xsl:stylesheet version=2.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output indent=yes/> <xsl:strip-space elements=*/> <xsl:template match=node()|@*>

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.