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

The Archive Base Latest Questions

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

All, I have an XML file which I transform it using an XSLT document

  • 0

All,

I have an XML file which I transform it using an XSLT document to another XML.

Can I define another set of transformations in the same XSLT file to be applied in the result XML of the first transformation?

Thanks,

MK

  • 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-16T16:46:30+00:00Added an answer on May 16, 2026 at 4:46 pm

    Yes.

    I. This XSLT 1.0 transformation:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common"
     xmlns:msxsl="urn:schemas-microsoft-com:xslt"
     >
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:variable name="vrtfPass1">
      <xsl:apply-templates/>
     </xsl:variable>
    
     <xsl:template match="node()|@*" name="identity">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="node()|@*" mode="pass2">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*" mode="pass2"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="num/text()">
      <xsl:value-of select="2*."/>
     </xsl:template>
    
     <xsl:template match="num/text()" mode="pass2">
      <xsl:value-of select="1+."/>
     </xsl:template>
    
     <xsl:template match="/">
      <xsl:apply-templates select="ext:node-set($vrtfPass1)/*" mode="pass2"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on this XML document:

    <t>
     <num>1</num>
     <num>2</num>
     <num>3</num>
     <num>4</num>
     <num>5</num>
    </t>
    

    produces:

    <t>
        <num>3</num>
        <num>5</num>
        <num>7</num>
        <num>9</num>
        <num>11</num>
    </t>
    

    Do note:

    1. Two transformations are actually performed, the second is performed on the result of the first.

    2. The result of the first transformation is the content of the variable $vrtfPass1.

    3. In XSLT 1.0 the type of variables that contain dynamically generated (temporary) XML trees (XML document or XML fragment) is RTF (Result-Tree-Fragment). No XPath operations are possible on an RTF — it needs to be converted to a regular node-set using the extension function xxx:node-set(), which is provided by the vast majority of XSLT 1.0 processor vendors. In this example exslt:node-set() is used, because EXSLT is implemented by many different vendors.

    4. The second transformation is applied on the result of the first: <xsl:apply-templates select="ext:node-set($vrtfPass1)/*" mode="pass2"/> . A separate mode is used in order to cleanly separate the code of the two transformations.

    5. The first transformation multiplies each num/text() by 2. The second transformation increments each num/text(). The result is 2*.+1

    II. This XSLT 2.0 transformation:

    <xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:xs="http://www.w3.org/2001/XMLSchema" >
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:variable name="vPass1">
      <xsl:apply-templates mode="pass1"/>
     </xsl:variable>
    
     <xsl:template match="node()|@*" mode="pass1">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*" mode="pass1"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="node()|@*" mode="pass2">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*" mode="pass2"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="num/text()" mode="pass1">
      <xsl:value-of select="2*xs:integer(.)"/>
     </xsl:template>
    
     <xsl:template match="num/text()" mode="pass2">
      <xsl:value-of select="1+."/>
     </xsl:template>
    
     <xsl:template match="/">
      <xsl:apply-templates select="$vPass1"  mode="pass2"/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the same XML document, produces the same wanted and correct result.

    Do note: In XSLT 2.0/XPath 2.0 the RTF type has been abolished. No xxx:node-set() extension function is needed.

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

Sidebar

Related Questions

I have an XML(XHTML) file which I'm transforming into another XML file by using
I have set up multiple targets in a single xml file. I expect all
Do you have some predefined set of targets which all build.xml files you create
I have a xml file which I want to edit using automatic data binding
I have an xml document which I transform, view in the browser and save
I would like to create a XML file which would have all the information
Hi all I have an XML file in java which holds a 2d array
I have this XML file from which I'm grabbing all the data: <?xml version=1.0
I have an XML file and I need to extract testname from all the
I have defined a local mirror for all repositories in the settings.xml file: <mirror>

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.