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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:21:42+00:00 2026-06-09T16:21:42+00:00

I am trying to split an value from xml using XSLT1.0 i have a

  • 0

I am trying to split an value from xml using XSLT1.0 i have a XML like

<employees>
    <examples>
       <example id="1,2,3">
       </example>
    </examples>

   <emp id="1">
     <name>john</name>
   </emp>
   <emp id="2">
     <name>raj</name>
   </emp>
   <emp id="3">
     <name>sat</name>
   </emp>

</employees>

I need to extract the id from the example tag and split it and get the value from the emp tag say the output should be

<employees>
    <employee>
        <id>1</id>
        <name>john</name>
    </employee>
    <employee>
        <id>2</id>
        <name>raj</name>
    </employee>
    <employee>
        <id>3</id>
        <name>sat</name>
    </employee>

</employees>
  • 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-09T16:21:44+00:00Added an answer on June 9, 2026 at 4:21 pm

    I think than rather than trying to split the @id attribute on the example element, which is a bit messy in XSLT1-0, you could instead try and match the emp elements whose @id appears in the @id of the attribute

     <xsl:variable name="ids" select="concat(',', examples/example/@id, ',')"/>
     <xsl:apply-templates select="emp[contains($ids, concat(',', @id, ','))]"/>
    

    Note the use of commas to ensure an @id of 1 is not picked up by an example @id of 11

    Here is the full XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
    
       <xsl:template match="employees">
          <employees>
             <xsl:variable name="ids" select="concat(',', examples/example/@id, ',')"/>
             <xsl:apply-templates select="emp[contains($ids, concat(',', @id, ','))]"/>
          </employees>
       </xsl:template>
    
       <xsl:template match="emp">
          <employee>
             <id>
                <xsl:value-of select="@id"/>
             </id>
             <xsl:apply-templates select="node()"/>
          </employee>
       </xsl:template>
    
       <xsl:template match="@*|node()">
          <xsl:copy>
             <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
       </xsl:template>
    </xsl:stylesheet>
    

    When applied to your sample XML, the following is output

    <employees>
       <employee>
          <id>1</id>
          <name>john</name>
       </employee>
       <employee>
          <id>2</id>
          <name>raj</name>
       </employee>
       <employee>
          <id>3</id>
          <name>sat</name>
       </employee>
    </employees>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pull in an src value from an XML document, and in
I have been trying to move away from using DECODE to pivot rows in
I am trying to read from an ncx file (i.e. xml file) using XElement:
Trying to split this string 主楼怎么走 into separate characters (I need an array) using
I'm trying to split strings in C# like this COMMSTR1-NAC-NAM-P-C FCPANAM1-NAC-NAM-P-C CHAZEL1-NAT-CBM-P-C should be
I am trying to split Scala list like List(1,2,3,4) into pairs (1,2) (2,3) (3,4)
I am trying to split a string in Javascript using a Regular Expression. My
I am trying to split a string from a recordset that is in the
I'm trying to split a diff (unified format) into each section using the re
I have an app that is built from Flash CS5.5, exported using AIR3.1 and

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.