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 4056026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:46:30+00:00 2026-05-20T14:46:30+00:00

I have a following scenario. I have a TEAM-MEMBERS node which has name in

  • 0

I have a following scenario. I have a TEAM-MEMBERS node which has name in the format last name, first name

<TEAM-MEMBER><LONG-NAME>Last Name, First Name</LONG-NAME></TEAM-MEMBER>

I want to transform this to

<CONTACT><FIRSTNAME>First Name</FIRSTNAME><LASTNAME>Last Name</LASTNAME></CONTACT>

Basically i want to split the <LONG-NAME> node’s value by ,

How can I achieve this using XSLT 1.0

This XSLT will be consumed by BizTalk Server hence i am looking for some XSLT 1.0 solutions only

Thanks

Karthik

  • 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-20T14:46:30+00:00Added an answer on May 20, 2026 at 2:46 pm

    Here is a complete XSLT 1.0 solution that uses a general “split” template that splits a string into multiple substrings, provided a delimiter to designate the boundary between substrings:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common" exclude-result-prefixes="ext">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
    
     <xsl:template match="TEAM-MEMBER">
      <xsl:variable name="vrtfSplitWords">
       <xsl:call-template name="split">
        <xsl:with-param name="pText" select="."/>
       </xsl:call-template>
      </xsl:variable>
    
      <xsl:variable name="vSplitWords"
      select="ext:node-set($vrtfSplitWords)/*"/>
    
      <CONTACT>
       <FIRSTNAME><xsl:value-of select="$vSplitWords[2]"/></FIRSTNAME>
       <LASTNAME><xsl:value-of select="$vSplitWords[1]"/></LASTNAME>
      </CONTACT>
     </xsl:template>
    
     <xsl:template name="split">
      <xsl:param name="pText" select="."/>
      <xsl:param name="pDelim" select="', '"/>
      <xsl:param name="pElemName" select="'word'"/>
    
      <xsl:if test="string-length($pText)">
       <xsl:element name="{$pElemName}">
        <xsl:value-of select=
         "substring-before(concat($pText,$pDelim),
                           $pDelim
                          )
         "/>
       </xsl:element>
    
       <xsl:call-template name="split">
        <xsl:with-param name="pText" select=
        "substring-after($pText,$pDelim)"/>
        <xsl:with-param name="pDelim" select="$pDelim"/>
        <xsl:with-param name="pElemName" select="$pElemName"/>
       </xsl:call-template>
      </xsl:if>
     </xsl:template>
    </xsl:stylesheet>
    

    When this transformation is applied on the provided XML document:

    <TEAM-MEMBER><LONG-NAME>Last Name, First Name</LONG-NAME></TEAM-MEMBER>
    

    the wanted, correct result is produced:

    <CONTACT>
       <FIRSTNAME>First Name</FIRSTNAME>
       <LASTNAME>Last Name</LASTNAME>
    </CONTACT>
    

    II. Solution using FXSL

    This transformation uses the str-split-to-words template from FXSL:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common"
     exclude-result-prefixes="ext"
    >
      <xsl:import href="strSplit-to-Words.xsl"/>
      <xsl:output indent="yes" omit-xml-declaration="yes"/>
    
       <xsl:strip-space elements="*"/>
       <xsl:output indent="yes" omit-xml-declaration="yes"/>
    
       <xsl:param name="pmaxLines" select="10"/>
    
        <xsl:template match="/">
          <xsl:variable name="vwordNodes">
            <xsl:call-template name="str-split-to-words">
              <xsl:with-param name="pStr" select="/"/>
              <xsl:with-param name="pDelimiters"
                              select="',()'"/>
            </xsl:call-template>
          </xsl:variable>
    
          <xsl:apply-templates select=
           "ext:node-set($vwordNodes)/*[normalize-space()]"/>
    
        </xsl:template>
    
        <xsl:template match="word[normalize-space()][1]">
          <FIRSTNAME>
           <xsl:value-of select="normalize-space()"/>
          </FIRSTNAME>
        </xsl:template>
    
        <xsl:template match="word[normalize-space()][2]">
          <MIDNAME>
           <xsl:value-of select="normalize-space()"/>
          </MIDNAME>
        </xsl:template>
    
        <xsl:template match="word[normalize-space()][last()]">
          <LASTNAME>
           <xsl:value-of select="normalize-space(.)"/>
          </LASTNAME>
        </xsl:template>
    </xsl:stylesheet>
    

    when applied to this XML document (made quite more complex):

    <TEAM-MEMBER><LONG-NAME>First Name, (Jr.), Last Name</LONG-NAME></TEAM-MEMBER>
    

    the wanted, correct result is produced:

    <FIRSTNAME>First Name</FIRSTNAME>
    <MIDNAME>Jr.</MIDNAME>
    <LASTNAME>Last Name</LASTNAME>
    

    Do Note:

    The str-split-to-words template accepts multiple delimiters. Thus in this transformation the delimiters used are: ',', '(' and ')'

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

Sidebar

Related Questions

I have the following scenario. I'm working with a server which has a lib
I am interested in the following scenario specifically. Suppose you have team that writes
I have the following scenario where I want to pass in string and a
I have the following scenario. The client code only has access to FooHandler, not
I have following scenario: alt text http://static.zooomr.com/images/7579022_e64808b855_o.png We have a WebService which poses as
Have the following scenario. I have a few form, which essentially have a few
I have the following scenario: 1 List which contains the months of the year:
I have the following scenario: I have five fields in my database (name, email,
I have the following scenario: My page has a dropdown list that allows user
I want a mysql query for following scenario I have following database structure 1]

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.