[PATCH 1/3] contrib: add an XSLT style sheet to create an account list

Florian Haas workflo at gmx.net
Tue Aug 16 15:13:10 EDT 2011


Add a simple XSLT style sheet that takes an (uncompressed) GnuCash
file or template, and generates a comma-separated list of account
numbers, names, and types.
---
 contrib/xslt/acctlist.xsl |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
 create mode 100644 contrib/xslt/acctlist.xsl

diff --git a/contrib/xslt/acctlist.xsl b/contrib/xslt/acctlist.xsl
new file mode 100644
index 0000000..ea51b20
--- /dev/null
+++ b/contrib/xslt/acctlist.xsl
@@ -0,0 +1,41 @@
+<xsl:stylesheet version="1.0" 
+		xmlns="http://www.gnucash.org/XML/"
+		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		xmlns:gnc="http://www.gnucash.org/XML/gnc"
+		xmlns:act="http://www.gnucash.org/XML/act">
+  <xsl:output method="text" encoding="utf-8"/>
+  <xsl:strip-space elements="*"/>
+
+  <xsl:param name="separator">,</xsl:param>
+
+  <xsl:param name="quote">"</xsl:param>
+
+  <xsl:param name="newline">
</xsl:param>
+
+  <xsl:template match="/">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="gnc-v2|gnc:book|gnc-account-example">
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="gnc:account">
+    <xsl:apply-templates select="act:code"/>
+    <xsl:value-of select="$separator"/>
+    <xsl:apply-templates select="act:name"/>
+    <xsl:value-of select="$separator"/>
+    <xsl:apply-templates select="act:type"/>
+    <xsl:text>
</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="act:code|act:name|act:type">
+    <xsl:value-of select="$quote"/>
+    <xsl:value-of select="."/>
+    <xsl:value-of select="$quote"/>
+  </xsl:template>
+
+  <xsl:template match="*"/>
+
+</xsl:stylesheet>
+  
-- 
1.7.1



More information about the gnucash-devel mailing list