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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:15:58+00:00 2026-06-15T03:15:58+00:00

The xslt I’m currently using generates all the tags on the root. I need

  • 0

The xslt I’m currently using generates all the tags on the root.
I need to get the <row> sets and <config> set.

Source Xml:

<root>
    <postdate>2011-03-30</postdate>
    <location>84</location>
    <meal>07:36</meal>
    <config>
        <postdate>2011-03-30</postdate>
        <location>84</location>
        <meal>07:36</meal>
        <checknumber>91339082011-03-30T07:36:12</checknumber>
    </config>
    <items>
        <row>
            <descriptor>7297364</descriptor>
            <qty>1</qty>
            <price>33</price>
            <value>33</value>
            <recordtype>1</recordtype>
            <postdate>2011-03-30</postdate>
            <location>84</location>
        </row>
        <row>
            <descriptor>7794473</descriptor>
            <qty>1</qty>
            <price>60</price>
            <value>60</value>
            <recordtype>1</recordtype>
            <postdate>2011-03-30</postdate>
            <location>84</location>
        </row>
    </items>
    <tenders>
        <row>
            <id>13</id>
            <value>117.99</value>
            <recordtype>2</recordtype>
            <postdate>2011-03-30</postdate>
            <location>84</location>
        </row>
    </tenders>
    <taxes>
        <row>
            <id>2</id>
            <value>8.25</value>
            <recordtype>3</recordtype>
            <postdate>2011-03-30</postdate>
            <location>84</location>
        </row>
    </taxes>
</root>

Attempted Xslt:

<xsl:stylesheet version="1.0" exclude-result-prefixes="msxsl" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
    <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
    <xsl:template match="row/*">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

Desired Output:

<root>
    <config>
        <postdate>2011-03-30</postdate>
        <location>84</location>
        <meal>07:36</meal>
        <checknumber>91339082011-03-30T07:36:12</checknumber>
    </config>
    <row>
        <descriptor>7297364</descriptor>
        <qty>1</qty>
        <price>33</price>
        <value>33</value>
        <recordtype>1</recordtype>
        <postdate>2011-03-30</postdate>
        <location>84</location>
    </row>
    <row>
        <descriptor>7794473</descriptor>
        <qty>1</qty>
        <price>60</price>
        <value>60</value>
        <recordtype>1</recordtype>
        <postdate>2011-03-30</postdate>
        <location>84</location>
    </row>
    <row>
        <id>13</id>
        <value>117.99</value>
        <recordtype>2</recordtype>
        <postdate>2011-03-30</postdate>
        <location>84</location>
    </row>
    <row>
        <id>2</id>
        <value>8.25</value>
        <recordtype>3</recordtype>
        <postdate>2011-03-30</postdate>
        <location>84</location>
    </row>
</root>
  • 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-15T03:16:00+00:00Added an answer on June 15, 2026 at 3:16 am

    This short and simple transformation:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:template match="node()|@*">
         <xsl:copy>
           <xsl:apply-templates select="node()|@*"/>
         </xsl:copy>
     </xsl:template>
    
     <xsl:template match=
      "node()[not(self::root or ancestor-or-self::config or ancestor-or-self::row)]">
      <xsl:apply-templates/>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <root>
        <postdate>2011-03-30</postdate>
        <location>84</location>
        <meal>07:36</meal>
        <config>
            <postdate>2011-03-30</postdate>
            <location>84</location>
            <meal>07:36</meal>
            <checknumber>91339082011-03-30T07:36:12</checknumber>
        </config>
        <items>
            <row>
                <descriptor>7297364</descriptor>
                <qty>1</qty>
                <price>33</price>
                <value>33</value>
                <recordtype>1</recordtype>
                <postdate>2011-03-30</postdate>
                <location>84</location>
            </row>
            <row>
                <descriptor>7794473</descriptor>
                <qty>1</qty>
                <price>60</price>
                <value>60</value>
                <recordtype>1</recordtype>
                <postdate>2011-03-30</postdate>
                <location>84</location>
            </row>
        </items>
        <tenders>
            <row>
                <id>13</id>
                <value>117.99</value>
                <recordtype>2</recordtype>
                <postdate>2011-03-30</postdate>
                <location>84</location>
            </row>
        </tenders>
        <taxes>
            <row>
                <id>2</id>
                <value>8.25</value>
                <recordtype>3</recordtype>
                <postdate>2011-03-30</postdate>
                <location>84</location>
            </row>
        </taxes>
    </root>
    

    produces the wanted, correct result:

    <root>
       <config>
          <postdate>2011-03-30</postdate>
          <location>84</location>
          <meal>07:36</meal>
          <checknumber>91339082011-03-30T07:36:12</checknumber>
       </config>
       <row>
          <descriptor>7297364</descriptor>
          <qty>1</qty>
          <price>33</price>
          <value>33</value>
          <recordtype>1</recordtype>
          <postdate>2011-03-30</postdate>
          <location>84</location>
       </row>
       <row>
          <descriptor>7794473</descriptor>
          <qty>1</qty>
          <price>60</price>
          <value>60</value>
          <recordtype>1</recordtype>
          <postdate>2011-03-30</postdate>
          <location>84</location>
       </row>
       <row>
          <id>13</id>
          <value>117.99</value>
          <recordtype>2</recordtype>
          <postdate>2011-03-30</postdate>
          <location>84</location>
       </row>
       <row>
          <id>2</id>
          <value>8.25</value>
          <recordtype>3</recordtype>
          <postdate>2011-03-30</postdate>
          <location>84</location>
       </row>
    </root>
    

    Explanation:

    1. Using and overriding the identity rule.

    2. Proper use of the ancestor-or-self:: axis.

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

Sidebar

Related Questions

Using XSLT, how can I get all member names associated with the tag A
Using xslt/xpath, I need to be able to select the two elements which have
Using XSLT 1.0, I want to process four node sets, in order, A, B,
Using XSLT, I need to remove a complete table column (header + body cells)
In XSLT, using , it generates a line break before the rendered value and
XML/XSLT Newbie here. I have some sets of data that need to be compared.
An XSLT-newbie problem: I need to substitute a text value in XML-file. All other
Using XSLT, how can one remove all the text nodes from HTML, but keep
Using XSLT 1.0, I'm trying to essentially create a small node set and then
I'm using XSLT to process my ASP.Net web.config file to insert some extra log4net

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.