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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:39:17+00:00 2026-05-23T00:39:17+00:00

I’m having a little issue with some XSLT. My original XML looks like this:

  • 0

I’m having a little issue with some XSLT.

My original XML looks like this:

<?xml version="1.0"?><rowset>
  <row>
    <trans_type>10</trans_type>
    <creation_date>2011-06-07</creation_date>
    <system_id>1039</system_id>
    <transaction_set>
      <transaction>
        <trans_type>10</trans_type>
        <client_id>977400</client_id>
        <case_id>12881459</case_id>
        <invoice_no>01/2011</invoice_no>
        <payment_date>110606</payment_date>
        <payment>710,08</payment>
        <currency>EUR</currency>
        <comment>
          <record_type>612</record_type>
          <comment_text>Asiakas maksoi lisäksi kesäkuun vuokran ajalle 1.6. - 15.6.2</comment_text>
        </comment>
        <comment>
          <record_type>612</record_type>
          <comment_text>011. Meillä saldo 0 €.</comment_text>
        </comment>
      </transaction>
    </transaction_set>
    <subtotal>
      <trans_type>10</trans_type>
      <count>25</count>
    </subtotal>
  </row>
</rowset>

My XSLT looks like this:

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <rowset>
      <xsl:for-each select="rowset/row/transaction_set/transaction">
        <row>
          <xsl:copy-of select="../../trans_type"/>
          <xsl:copy-of select="../../creation_date"/>
          <xsl:copy-of select="../../subtotal"/>
          <xsl:copy-of select="."/>
          <xsl:copy-of select="./client_id"/>
          <comment_text><xsl:for-each select="./comment"><xsl:value-of select="./comment_text"/></xsl:for-each></comment_text>
        </row>
      </xsl:for-each>
    </rowset>
</xsl:template>
</xsl:stylesheet> 

…and my output looks like this:

<?xml version='1.0' ?>
<rowset>
  <row>
    <trans_type>10</trans_type>
    <creation_date>2011-06-07</creation_date>
    <subtotal>
      <trans_type>10</trans_type>
      <count>25</count>
    </subtotal>
    <transaction>
      <trans_type>10</trans_type>
      <client_id>977400</client_id>           <!--need this gone-->
      <case_id>12881459</case_id>
      <invoice_no>01/2011</invoice_no>
      <payment_date>110606</payment_date>
      <payment>710,08</payment>
      <currency>EUR</currency>                <!--need this gone-->
      <comment>                               <!--need this gone-->
        <record_type>612</record_type>
        <comment_text>Asiakas maksoi lisäksi kesäkuun vuokran ajalle 1.6. - 15.6.2</comment_text>
      </comment>
      <comment>                               <!--need this gone-->
        <record_type>612</record_type>
        <comment_text>011. Meillä saldo 0 €.</comment_text>
      </comment>
    </transaction>
    <client_id>977400</client_id>
    <comment_text>Asiakas maksoi lisäksi kesäkuun vuokran ajalle 1.6. - 15.6.2011. Meillä saldo 0 €.</comment_text>
  </row>
</rowset>

I need to remove the following tags from my output \rowset\row\transaction\comment, \rowset\row\transaction\client_idand \rowset\row\transcation\currency. Although I’ve managed to twist the XML to almost how I want it, I can’t seem to remove the nodes I don’t want.

In the original XML there can be more than one transaction in transaction_set and each transaction can contain multiple comment. I’m trying to concatenate all the comment\comment_text records which I’ve managed to do but I need these comment tags removed from \rowset\row\transaction in the output XML.

Maybe I’m tackling this in the wrong way but I can’t get my head around it.

  • 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-23T00:39:18+00:00Added an answer on May 23, 2026 at 12:39 am

    An easier way to approach this is to take an identity transform (i.e. one which simply copies each element / attribute), then add no-op matches for the elements you wish to omit:

    <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="*"/>
    
     <!-- identity -->
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <!-- add elements that you want to omit here -->
     <xsl:template match="//client_id"/>
     <xsl:template match="//comment"/>
     ...
    
    </xsl:stylesheet>
    

    See this related question:

    XSL Transform remove Xml Elements

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.