aboutsummaryrefslogtreecommitdiffstats
path: root/src/codegen
diff options
context:
space:
mode:
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>