[thelist] XSLT XML output to XML
David Johansson
thelist at dlade.net
Sat Apr 14 02:57:12 CDT 2007
Jon Molesa wrote:
> My understand of XML, XSLT is limited practical experience. I've read
> quite a bit but this is the first real reason I've ever had to try and
> practice. The rub is that I need this to complete my taxes. I want to
> transform the file into the same file minus the Invoices.
What you want is called the Identity Transform. See
http://www.dpawson.co.uk/xsl/sect2/identity.html for more information
about that (and http://www.dpawson.co.uk/xsl/sect2/sect21.html for the
rest of Dave Pawson's brilliant FAQ collected from the xsl-list at
Mulberrytech).
In your case, the XSLT would look something like this:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gnc="http://www.gnucash.org/XML/gnc"
xmlns:slot="http://www.gnucash.org/XML/slot"
>
<!-- Whenever you match any node or any attribute -->
<xsl:template match="node()|@*">
<!-- Copy the current node -->
<xsl:copy>
<!-- Including any attributes it has and any child nodes -->
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="gnc:transaction[.//slot:key]"></xsl:template>
</xsl:stylesheet>
So the first template matches on absolutely everything and copies
whatever it finds, while the second template matches specifically on
gnc:transaction elements with descendant slot:key elements and does nothing.
HTH,
David
More information about the thelist
mailing list