backport ocy's branch
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 09 Feb 2010 14:11:08 +0100
changeset 33 98eba9e700ed
parent 30 fbaa1e593b46 (current diff)
parent 32 85a1b82d6a72 (diff)
child 34 b3296b035519
backport ocy's branch
views/accounting.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/accounting-entries.xsl	Tue Feb 09 14:11:08 2010 +0100
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+  <xsl:output method="text" encoding="UTF-8"/>
+
+  <xsl:template match="*">
+    <xsl:param name="indent" select="''"/>
+
+    <xsl:call-template name="write-element">
+      <xsl:with-param name="indent" select="$indent"/>
+    </xsl:call-template>
+  </xsl:template>
+
+  <xsl:template match="ecriture">
+    <xsl:param name="indent" select="''"/>
+
+    <xsl:call-template name="write-element">
+      <xsl:with-param name="indent" select="$indent"/>
+    </xsl:call-template>
+    <xsl:if test="following-sibling::ecriture">
+      <xsl:text>
+</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="@*">
+    <xsl:text> </xsl:text>
+    <xsl:value-of select="name()"/>
+    <xsl:text>="</xsl:text>
+    <xsl:value-of select="."/>
+    <xsl:text>"</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="text()">
+    <xsl:if test="normalize-space(.)">
+      <xsl:value-of select="."/>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template name="write-element">
+    <xsl:param name="indent" select="''"/>
+
+    <xsl:text>
+</xsl:text>
+    <xsl:value-of select="$indent"/>
+    <xsl:text>&lt;</xsl:text>
+    <xsl:value-of select="name()"/>
+    <xsl:apply-templates select="@*">
+      <xsl:sort select="name()"/>
+    </xsl:apply-templates>
+    <xsl:if test="not(*|text())">
+      <xsl:text>/</xsl:text>
+    </xsl:if>
+    <xsl:text>></xsl:text>
+
+    <xsl:if test="*|text()">
+      <xsl:apply-templates select="*|text()">
+	<xsl:with-param name="indent" select="concat($indent,'  ')"/>
+      </xsl:apply-templates>
+
+      <xsl:if test="*">
+	<xsl:text>
+</xsl:text>
+        <xsl:value-of select="$indent"/>
+      </xsl:if>
+      <xsl:text>&lt;/</xsl:text>
+      <xsl:value-of select="name()"/>
+      <xsl:text>></xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+</xsl:stylesheet>
--- a/views/accounting.py	Tue Feb 09 13:46:00 2010 +0100
+++ b/views/accounting.py	Tue Feb 09 14:11:08 2010 +0100
@@ -25,6 +25,8 @@
         """display a list of entities by calling their <item_vid> view
         """
         self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding)
+        self.w(u'<?xml-stylesheet href="%saccounting-entries.xsl" '
+               u'rel="stylesheet" type="text/xsl"?>\n' % self._cw.datadir_url)
         self.w(u'<ecritures>\n')
         for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)
@@ -49,6 +51,8 @@
         """display a list of entities by calling their <item_vid> view
         """
         self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self._cw.encoding)
+        self.w(u'<?xml-stylesheet href="%saccounting-entries.xsl" '
+               u'rel="stylesheet" type="text/xsl"?>\n' % self._cw.datadir_url)
         self.w(u'<ecritures>\n')
         for i in xrange(self.cw_rset.rowcount):
             self.cell_call(i, 0)