| 1 |
<!-- |
| 2 |
Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 |
contributor license agreements. See the NOTICE file distributed with |
| 4 |
this work for additional information regarding copyright ownership. |
| 5 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 |
(the "License"); you may not use this file except in compliance with |
| 7 |
the License. You may obtain a copy of the License at |
| 8 |
|
| 9 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
|
| 11 |
Unless required by applicable law or agreed to in writing, software |
| 12 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
See the License for the specific language governing permissions and |
| 15 |
limitations under the License. |
| 16 |
--> |
| 17 |
<!-- $Id$ --> |
| 18 |
<xsl:stylesheet version="1.0" |
| 19 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
| 20 |
|
| 21 |
<xsl:include href="./propinc.xsl"/> |
| 22 |
|
| 23 |
<xsl:output method="text" /> |
| 24 |
|
| 25 |
<xsl:template match="allprops"> |
| 26 |
<xsl:variable name="constlist"> |
| 27 |
<xsl:for-each select="document(propfile)//generic-property-list |
| 28 |
//enumeration/value"> |
| 29 |
<xsl:sort select="@const"/> |
| 30 |
<xsl:value-of select="@const"/>:</xsl:for-each> |
| 31 |
</xsl:variable> |
| 32 |
|
| 33 |
<xsl:variable name="propertylist"> |
| 34 |
<xsl:for-each select="document(propfile)//generic-property-list// |
| 35 |
property[not(@type = 'generic')]"> |
| 36 |
<xsl:sort select="name"/> |
| 37 |
<xsl:text>PR_</xsl:text> |
| 38 |
<xsl:call-template name="makeEnumConstant"> |
| 39 |
<xsl:with-param name="propstr" select="name" /> |
| 40 |
</xsl:call-template> |
| 41 |
<xsl:text>:</xsl:text> |
| 42 |
</xsl:for-each> |
| 43 |
</xsl:variable> |
| 44 |
|
| 45 |
<xsl:variable name="compoundpropertylist"> |
| 46 |
<xsl:for-each select="document(propfile)//generic-property-list// |
| 47 |
property/compound/subproperty"> |
| 48 |
<xsl:sort select="name"/> |
| 49 |
<xsl:text>CP_</xsl:text> |
| 50 |
<xsl:call-template name="makeEnumConstant"> |
| 51 |
<xsl:with-param name="propstr" select="name" /> |
| 52 |
</xsl:call-template> |
| 53 |
<xsl:text>:</xsl:text> |
| 54 |
</xsl:for-each> |
| 55 |
</xsl:variable> |
| 56 |
|
| 57 |
<xsl:variable name="elementlist"> |
| 58 |
<xsl:for-each select="document(elementfile)//element"> |
| 59 |
<xsl:sort select="name"/> |
| 60 |
<xsl:text>FO_</xsl:text> |
| 61 |
<xsl:call-template name="makeEnumConstant"> |
| 62 |
<xsl:with-param name="propstr" select="name" /> |
| 63 |
</xsl:call-template> |
| 64 |
<xsl:text>:</xsl:text> |
| 65 |
</xsl:for-each> |
| 66 |
</xsl:variable> |
| 67 |
|
| 68 |
<xsl:text> |
| 69 |
|
| 70 |
package org.apache.fop.fo; |
| 71 |
|
| 72 |
public interface Constants {</xsl:text> |
| 73 |
|
| 74 |
// element constants |
| 75 |
<xsl:call-template name="sortconsts"> |
| 76 |
<xsl:with-param name="consts" select="$elementlist"/> |
| 77 |
<xsl:with-param name="counter" select="'ELEMENT'"/> |
| 78 |
</xsl:call-template> |
| 79 |
|
| 80 |
// Masks |
| 81 |
int COMPOUND_SHIFT = 9; |
| 82 |
int PROPERTY_MASK = (1 << COMPOUND_SHIFT)-1; |
| 83 |
int COMPOUND_MASK = ~PROPERTY_MASK; |
| 84 |
int COMPOUND_COUNT = 11; |
| 85 |
|
| 86 |
// property constants |
| 87 |
<xsl:call-template name="sortconsts"> |
| 88 |
<xsl:with-param name="consts" select="$propertylist"/> |
| 89 |
<xsl:with-param name="counter" select="'PROPERTY'"/> |
| 90 |
</xsl:call-template> |
| 91 |
|
| 92 |
// compound property constants |
| 93 |
<xsl:call-template name="sortconsts"> |
| 94 |
<xsl:with-param name="consts" select="$compoundpropertylist"/> |
| 95 |
<xsl:with-param name="suffix" select="' << COMPOUND_SHIFT'"/> |
| 96 |
</xsl:call-template> |
| 97 |
|
| 98 |
// Enumeration constants |
| 99 |
<xsl:call-template name="sortconsts"> |
| 100 |
<xsl:with-param name="consts" select="$constlist"/> |
| 101 |
</xsl:call-template> |
| 102 |
|
| 103 |
// Enumeration Interfaces |
| 104 |
|
| 105 |
public interface GenericBooleanInterface { |
| 106 |
int TRUE = Constants.TRUE; |
| 107 |
int FALSE = Constants.FALSE; |
| 108 |
} |
| 109 |
|
| 110 |
public interface GenericBorderStyleInterface { |
| 111 |
int NONE = Constants.NONE; |
| 112 |
int HIDDEN = Constants.HIDDEN; |
| 113 |
int DOTTED = Constants.DOTTED; |
| 114 |
int DASHED = Constants.DASHED; |
| 115 |
int SOLID = Constants.SOLID; |
| 116 |
int DOUBLE = Constants.DOUBLE; |
| 117 |
int GROOVE = Constants.GROOVE; |
| 118 |
int RIDGE = Constants.RIDGE; |
| 119 |
int INSET = Constants.INSET; |
| 120 |
int OUTSET = Constants.OUTSET; |
| 121 |
} |
| 122 |
|
| 123 |
public interface GenericBreakInterface { |
| 124 |
int AUTO = Constants.AUTO; |
| 125 |
int COLUMN = Constants.COLUMN; |
| 126 |
int PAGE = Constants.PAGE; |
| 127 |
int EVEN_PAGE = Constants.EVEN_PAGE; |
| 128 |
int ODD_PAGE = Constants.ODD_PAGE; |
| 129 |
} |
| 130 |
|
| 131 |
public interface GenericCondBorderWidthInterface { |
| 132 |
public interface Conditionality { |
| 133 |
int DISCARD = Constants.DISCARD; |
| 134 |
int RETAIN = Constants.RETAIN; |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
public interface GenericCondPaddingInterface { |
| 139 |
public interface Conditionality { |
| 140 |
int DISCARD = Constants.DISCARD; |
| 141 |
int RETAIN = Constants.RETAIN; |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
public interface GenericKeepInterface { |
| 146 |
public interface WithinPage { |
| 147 |
int AUTO = Constants.AUTO; |
| 148 |
int ALWAYS = Constants.ALWAYS; |
| 149 |
} |
| 150 |
public interface WithinLine { |
| 151 |
int AUTO = Constants.AUTO; |
| 152 |
int ALWAYS = Constants.ALWAYS; |
| 153 |
} |
| 154 |
public interface WithinColumn { |
| 155 |
int AUTO = Constants.AUTO; |
| 156 |
int ALWAYS = Constants.ALWAYS; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
public interface GenericSpaceInterface { |
| 161 |
public interface Precedence { |
| 162 |
int FORCE = Constants.FORCE; |
| 163 |
} |
| 164 |
public interface Conditionality { |
| 165 |
int DISCARD = Constants.DISCARD; |
| 166 |
int RETAIN = Constants.RETAIN; |
| 167 |
} |
| 168 |
} |
| 169 |
|
| 170 |
<xsl:apply-templates select = "document(propfile)//property[not(@type='generic')]"> |
| 171 |
<xsl:sort select="name"/> |
| 172 |
</xsl:apply-templates> |
| 173 |
|
| 174 |
<xsl:text> |
| 175 |
} |
| 176 |
</xsl:text> |
| 177 |
</xsl:template> |
| 178 |
|
| 179 |
<xsl:template match="property"> |
| 180 |
<xsl:variable name="classname"> |
| 181 |
<xsl:choose> |
| 182 |
<xsl:when test="class-name"> |
| 183 |
<xsl:value-of select="class-name"/> |
| 184 |
</xsl:when> |
| 185 |
<xsl:otherwise> |
| 186 |
<xsl:call-template name="makeClassName"> |
| 187 |
<xsl:with-param name="propstr" select="name"/> |
| 188 |
</xsl:call-template> |
| 189 |
</xsl:otherwise> |
| 190 |
</xsl:choose> |
| 191 |
</xsl:variable> |
| 192 |
<xsl:variable name="bEnum"> |
| 193 |
<xsl:call-template name="hasEnum"/> |
| 194 |
</xsl:variable> |
| 195 |
<xsl:variable name="bSubpropEnum"> |
| 196 |
<xsl:call-template name="hasSubpropEnum"/> |
| 197 |
</xsl:variable> |
| 198 |
|
| 199 |
<xsl:if test="$bEnum='true' or contains($bSubpropEnum, 'true')"> |
| 200 |
<!--redirect:write select="concat($classname, '.java')"--> |
| 201 |
<!-- Handle enumeration values --> |
| 202 |
<xsl:text> |
| 203 |
public interface </xsl:text> |
| 204 |
<xsl:value-of select="$classname"/> |
| 205 |
<xsl:if test="use-generic"> |
| 206 |
<xsl:text> extends </xsl:text> |
| 207 |
<xsl:value-of select="use-generic"/> |
| 208 |
<xsl:text>Interface</xsl:text> |
| 209 |
</xsl:if> |
| 210 |
<xsl:text> {</xsl:text> |
| 211 |
<xsl:for-each select="enumeration/value"> |
| 212 |
<xsl:text> |
| 213 |
int </xsl:text> |
| 214 |
<xsl:value-of select="@const"/> |
| 215 |
<xsl:text> = Constants.</xsl:text> |
| 216 |
<xsl:value-of select="@const"/> |
| 217 |
<xsl:text>;</xsl:text> |
| 218 |
</xsl:for-each> |
| 219 |
<xsl:text> } |
| 220 |
</xsl:text> |
| 221 |
</xsl:if> |
| 222 |
</xsl:template> |
| 223 |
|
| 224 |
<xsl:template name="sortconsts"> |
| 225 |
<xsl:param name="consts"/> |
| 226 |
<xsl:param name="prevconst"/> |
| 227 |
<xsl:param name="num" select="1"/> |
| 228 |
<xsl:param name="suffix" select="''"/> |
| 229 |
<xsl:param name="counter" select="''"/> |
| 230 |
<xsl:variable name="cval" select="substring-before($consts,':')"/> |
| 231 |
<xsl:choose> |
| 232 |
<xsl:when test="$consts = ''"> |
| 233 |
<xsl:if test="$counter != ''"> |
| 234 |
<xsl:text> |
| 235 |
int </xsl:text> |
| 236 |
<xsl:value-of select="$counter"/>_COUNT = <xsl:value-of select="$num - 1"/>; |
| 237 |
</xsl:if> |
| 238 |
</xsl:when> |
| 239 |
<xsl:when test="$cval = $prevconst"> |
| 240 |
<xsl:call-template name="sortconsts"> |
| 241 |
<xsl:with-param name="consts" select="substring-after($consts,concat($cval, ':'))"/> |
| 242 |
<xsl:with-param name="num" select="$num"/> |
| 243 |
<xsl:with-param name="prevconst" select="$cval"/> |
| 244 |
<xsl:with-param name="counter" select="$counter"/> |
| 245 |
<xsl:with-param name="suffix" select="$suffix"/> |
| 246 |
</xsl:call-template> |
| 247 |
</xsl:when> |
| 248 |
<xsl:otherwise> |
| 249 |
<xsl:text> |
| 250 |
int </xsl:text> |
| 251 |
<xsl:value-of select="$cval"/> |
| 252 |
<xsl:text> = </xsl:text> |
| 253 |
<xsl:value-of select="$num"/> |
| 254 |
<xsl:value-of select="$suffix"/> |
| 255 |
<xsl:text>;</xsl:text> |
| 256 |
<xsl:call-template name="sortconsts"> |
| 257 |
<xsl:with-param name="consts" select="substring-after($consts,concat($cval, ':'))"/> |
| 258 |
<xsl:with-param name="num" select="$num + 1"/> |
| 259 |
<xsl:with-param name="prevconst" select="$cval"/> |
| 260 |
<xsl:with-param name="counter" select="$counter"/> |
| 261 |
<xsl:with-param name="suffix" select="$suffix"/> |
| 262 |
</xsl:call-template> |
| 263 |
</xsl:otherwise> |
| 264 |
</xsl:choose> |
| 265 |
</xsl:template> |
| 266 |
</xsl:stylesheet> |