I have a little problem with some XSLT.
My original XML is as follows:
<?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 conclusion is as follows:
<?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>
<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>
<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 managed to flip the XML almost the way I want it, I can’t delete the nodes I don’t want.
There can be more than one transactionin the source XML transaction_set, and each transactioncan contain several comment. I am trying to combine all the records comment\comment_textthat I managed to make, but I need these tags commentremoved from \rowset\row\transactionin the XML output.
Maybe I’ll solve it wrong, but I can’t lower my head.