aboutsummaryrefslogtreecommitdiffstats
path: root/src/codegen
diff options
context:
space:
mode:
authorKaren Lease <klease@apache.org>2001-03-04 21:21:19 +0000
committerKaren Lease <klease@apache.org>2001-03-04 21:21:19 +0000
commitf163e8fc28d6db4ef3194496c0d2014de86322a9 (patch)
tree89b0b1d19f719dc79eebf2fcfaaaaf8cc7476a07 /src/codegen
parent78d70e65dab7c3eb93ee3bea2c2c21f11d8d7610 (diff)
downloadxmlgraphics-fop-f163e8fc28d6db4ef3194496c0d2014de86322a9.tar.gz
xmlgraphics-fop-f163e8fc28d6db4ef3194496c0d2014de86322a9.zip
Generate a single interface for all constants
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194120 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/allprops.xml5
-rw-r--r--src/codegen/genconst.xsl46
2 files changed, 51 insertions, 0 deletions
diff --git a/src/codegen/allprops.xml b/src/codegen/allprops.xml
new file mode 100644
index 000000000..c171da7d6
--- /dev/null
+++ b/src/codegen/allprops.xml
@@ -0,0 +1,5 @@
+<allprops>
+<propfile>foproperties.xml</propfile>
+<propfile>svgproperties.xml</propfile>
+<propfile>extproperties.xml</propfile>
+</allprops>
diff --git a/src/codegen/genconst.xsl b/src/codegen/genconst.xsl
new file mode 100644
index 000000000..b67d4edd8
--- /dev/null
+++ b/src/codegen/genconst.xsl
@@ -0,0 +1,46 @@
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+
+<xsl:output method="text" />
+
+<xsl:template match="allprops">
+<xsl:variable name="constlist">
+ <xsl:for-each select="document(propfile)//enumeration/value">
+ <xsl:sort select="@const"/>
+ <xsl:value-of select="@const"/>:</xsl:for-each>
+</xsl:variable>
+package org.apache.fop.fo.properties;
+
+public interface Constants {
+ <xsl:call-template name="sortconsts">
+ <xsl:with-param name="consts" select="$constlist"/>
+ </xsl:call-template>
+}
+</xsl:template>
+
+<xsl:template name="sortconsts">
+<xsl:param name="consts"/>
+<xsl:param name="prevconst"/>
+<xsl:param name="num" select="1"/>
+<xsl:variable name="cval" select="substring-before($consts,':')"/>
+<xsl:choose>
+ <xsl:when test="$consts = ''"/>
+ <xsl:when test="$cval = $prevconst">
+ <xsl:call-template name="sortconsts">
+ <xsl:with-param name="consts" select="substring-after($consts,concat($cval, ':'))"/>
+ <xsl:with-param name="num" select="$num"/>
+ <xsl:with-param name="prevconst" select="$cval"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ public final static int <xsl:value-of select="$cval"/> = <xsl:value-of select="$num"/>;
+ <xsl:call-template name="sortconsts">
+ <xsl:with-param name="consts" select="substring-after($consts,concat($cval, ':'))"/>
+ <xsl:with-param name="num" select="$num + 1"/>
+ <xsl:with-param name="prevconst" select="$cval"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+</xsl:stylesheet>