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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:57:29+00:00 2026-06-05T00:57:29+00:00

I am working XSLT where the source looks like this. Source: <Data> <AB>all</AB> <AB>all2</AB>

  • 0

I am working XSLT where the source looks like this.

Source:

        <Data>
             <AB>all</AB>
             <AB>all2</AB>
             <CD>hhhhhh</CD>
             <DE>hhhshhh</DE>                
        </Data>

Need to write XSLT to get output as

   <Info>
        <XXX>
        <TTT value="all"/>
        <TTT value="all2"/>
        </XXX>
    <!--    ....-->
    <!--    ..to het all the elements..   -->

   </Info>

I have to write xslt to match tag.

    <xsl:template match="AB">


    </xsl:template>

I can do it by matching Data tag.

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>

         <xsl:template match="Data">
        <info>
          <XXX>
          <xsl:for-each select="AB">
          <TTT>
          <xsl:attribute name="value">
            <xsl:value-of select="."/>
          </xsl:attribute>
          </TTT>
          </xsl:for-each>
          </XXX>
        </info>
          </xsl:template>

    </xsl:stylesheet>

Can any one help me out how to do it by matching AB tag

    <xsl:template match="AB">


    </xsl:template>

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-05T00:57:31+00:00Added an answer on June 5, 2026 at 12:57 am

    I think you are asking how do you use xsl:apply-templates. If so, your XSLT would look like this

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
    
       <xsl:template match="Data">
          <info>
             <XXX>
                <xsl:apply-templates select="AB"/>
             </XXX>
          </info>
       </xsl:template>
    
       <xsl:template match="AB">
          <TTT value="{.}"/>
       </xsl:template>
    </xsl:stylesheet>
    

    Do also note the use of Attribute Value Templates in the AB template to simplify the XSLT.

    If you also require the other non-AB elements to be output unchanged, you would make use of the identity transform in your XSLT

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:output method="xml" indent="yes"/>
    
       <xsl:template match="Data">
          <info>
             <XXX>
                <xsl:apply-templates select="AB"/>
             </XXX>
             <xsl:apply-templates select="node()[not(self::AB)]" />
          </info>
       </xsl:template>
       <xsl:template match="AB">
          <TTT value="{.}"/>
       </xsl:template>
    
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>   
    </xsl:stylesheet>
    

    This would also match all non-AB elements, outputing following the XXX element. In your case, it would output the following:

    <info>
       <XXX>
          <TTT value="all" />
          <TTT value="all2" />
        </XXX>
        <CD>hhhhhh</CD>
        <DE>hhhshhh</DE>
    </info>
    

    Of course, there is no reason you couldn’t have other templates matching elements like CD or DE to transform those too.

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

Sidebar

Related Questions

I am working on call-template, where the source looks like this. Source: <Content> <first>
I'd like to get a real XSLT processor working with erlang. Which would be
I'm working on XSLT. I have this XML source file : <?xml version=1.0 encoding=UTF-8?>
I am working with an open source version of the Saxon XSLT processor Saxon
I'm working on a project that involves XSLT. And would like to use a
I am working on this from xslt cookbook type my.xml <?xml version=1.0 encoding=UTF-8?> <people>
I am working on XSLT transformations. I am stuck at one point. Source XML:
guys, recursion with grouping is not working. I am using XSLT 1.0. I need
I'm working with XSLT 1.0 from PHP and want to wrap all the sibling
I have a project that I'm working that uses XSLT to display data from

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.