You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

properties.xsl 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. <xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:lxslt="http://xml.apache.org/xslt"
  4. xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
  5. extension-element-prefixes="redirect">
  6. <xsl:include href="./propinc.xsl"/>
  7. <xsl:output method="text" />
  8. <xsl:template match="extfile">
  9. <!--<xsl:message>Do <xsl:value-of select="@href"/></xsl:message>-->
  10. <xsl:apply-templates select="document(@href)/*"/>
  11. </xsl:template>
  12. <!-- Content of element is code to calculate the base length -->
  13. <xsl:template match="percent-ok">
  14. /** Return object used to calculate base Length
  15. * for percent specifications.
  16. */
  17. public PercentBase getPercentBase(final FObj fo, final PropertyList propertyList) {
  18. <xsl:choose>
  19. <xsl:when test="@base">
  20. return new LengthBase(fo, propertyList, LengthBase.<xsl:value-of select="@base"/>);
  21. </xsl:when>
  22. <xsl:otherwise>
  23. return (new LengthBase(fo, propertyList, LengthBase.CUSTOM_BASE ) {
  24. public int getBaseLength() {
  25. return (<xsl:value-of select="."/>);
  26. }
  27. });
  28. </xsl:otherwise>
  29. </xsl:choose>
  30. }
  31. </xsl:template>
  32. <!-- Look for "auto" length keyword -->
  33. <xsl:template match="auto-ok">
  34. protected boolean isAutoLengthAllowed() {
  35. return true;
  36. }
  37. </xsl:template>
  38. <xsl:template match="enumeration">
  39. public Property checkEnumValues(String value) {
  40. <xsl:for-each select="value">
  41. <xsl:call-template name="enumvals">
  42. <xsl:with-param name="specvals" select="concat(.,' ')"/>
  43. </xsl:call-template>
  44. </xsl:for-each>
  45. return super.checkEnumValues(value);
  46. }
  47. </xsl:template>
  48. <!-- Look for keyword equivalents. Value is the new expression -->
  49. <xsl:template match="keyword-equiv[1]">
  50. // Initialize hashtable of keywords
  51. static Hashtable s_htKeywords;
  52. static {
  53. s_htKeywords = new Hashtable(<xsl:value-of select="count(../keyword-equiv)"/>);
  54. <xsl:for-each select="../keyword-equiv">
  55. s_htKeywords.put("<xsl:value-of select="@match"/>", "<xsl:value-of select="."/>");
  56. </xsl:for-each>
  57. }
  58. protected String checkValueKeywords(String keyword) {
  59. String value = (String)s_htKeywords.get(keyword);
  60. if (value == null) {
  61. return super.checkValueKeywords(keyword);
  62. }
  63. else return value;
  64. }
  65. </xsl:template>
  66. <xsl:template match="keyword-equiv[position()>1]"/>
  67. <!-- Generate code to convert from other datatypes to property datatype -->
  68. <xsl:template match='datatype-conversion[1]'>
  69. <xsl:variable name="propclass">
  70. <xsl:choose>
  71. <xsl:when test="../compound">
  72. <xsl:call-template name="propclass">
  73. <xsl:with-param name="prop"
  74. select="../compound/subproperty[@set-by-shorthand]"/>
  75. </xsl:call-template>
  76. </xsl:when><xsl:otherwise>
  77. <xsl:call-template name="propclass">
  78. <xsl:with-param name="prop" select=".."/>
  79. </xsl:call-template>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </xsl:variable>
  83. // See if other value types are acceptable
  84. protected Property convertPropertyDatatype(Property p,
  85. PropertyList propertyList, FObj fo) {
  86. <xsl:for-each select="../datatype-conversion">
  87. {
  88. <xsl:variable name="dtc">
  89. <xsl:choose>
  90. <xsl:when test="@vartype">
  91. <xsl:value-of select="@vartype"/>
  92. </xsl:when><xsl:otherwise>
  93. <xsl:value-of select="@from-type"/>
  94. </xsl:otherwise>
  95. </xsl:choose>
  96. </xsl:variable>
  97. <xsl:value-of select="$dtc"/><xsl:text> </xsl:text> <xsl:value-of select="@varname"/> =
  98. p.get<xsl:value-of select="@from-type"/>();
  99. if (<xsl:value-of select="@varname"/> != null) {
  100. return new <xsl:value-of select="$propclass"/>(
  101. <xsl:value-of select='.'/>);
  102. }
  103. }
  104. </xsl:for-each>
  105. return super.convertPropertyDatatype(p, propertyList, fo);
  106. }
  107. </xsl:template>
  108. <xsl:template match="datatype-conversion[position()>1]"/>
  109. <!-- generate getDefaultForXXX for property components -->
  110. <xsl:template match="default[@subproperty]" priority="2">
  111. <xsl:variable name="spname">
  112. <xsl:call-template name="makeClassName">
  113. <xsl:with-param name="propstr" select="@subproperty"/>
  114. </xsl:call-template>
  115. </xsl:variable>
  116. protected String getDefaultFor<xsl:value-of select='$spname'/>() {
  117. return "<xsl:value-of select='.'/>";
  118. }
  119. </xsl:template>
  120. <!-- generate default "make" method for non-compound properties -->
  121. <xsl:template match="default[not(../compound)]" priority="1">
  122. <xsl:if test='not(@contextdep = "true")'>
  123. private Property m_defaultProp=null;
  124. </xsl:if>
  125. public Property make(PropertyList propertyList) throws FOPException {
  126. <xsl:choose><xsl:when test='@contextdep="true"'>
  127. return make(propertyList, "<xsl:value-of select='.'/>", propertyList.getParentFObj());
  128. </xsl:when><xsl:otherwise>
  129. if (m_defaultProp == null) {
  130. m_defaultProp=make(propertyList, "<xsl:value-of select='.'/>", propertyList.getParentFObj());
  131. }
  132. return m_defaultProp;
  133. </xsl:otherwise></xsl:choose>
  134. }
  135. </xsl:template>
  136. <xsl:template match="text()"/>
  137. <!-- Ignore properties which reference others. Only for mapping! -->
  138. <xsl:template match="property[@type='ref']"/>
  139. <!-- Only if more explicit rules not matched (ref) -->
  140. <xsl:template match="property">
  141. <!-- Only create a specific class for those properties not based on
  142. template (generic) property definitions or which extends a
  143. generic definition.
  144. -->
  145. <xsl:if test='not(use-generic) or count(*)>2'>
  146. <xsl:variable name="eclassname">
  147. <xsl:choose>
  148. <xsl:when test="class-name">
  149. <xsl:value-of select="class-name"/>
  150. </xsl:when>
  151. <xsl:otherwise>
  152. <xsl:call-template name="makeClassName">
  153. <xsl:with-param name="propstr" select="name"/>
  154. </xsl:call-template>
  155. </xsl:otherwise>
  156. </xsl:choose>
  157. </xsl:variable>
  158. <xsl:variable name="classname">
  159. <xsl:value-of select="$eclassname"/><xsl:if test="not(@type='generic')">Maker</xsl:if>
  160. </xsl:variable>
  161. <!-- The class of the Property object to be created -->
  162. <xsl:variable name="propclass">
  163. <xsl:call-template name="propclass"/>
  164. </xsl:variable>
  165. <!-- The superclass for this PropertyMaker -->
  166. <xsl:variable name="superclass">
  167. <xsl:choose>
  168. <xsl:when test="use-generic[@ispropclass='true']">
  169. <xsl:value-of select="use-generic"/><xsl:text>.Maker</xsl:text>
  170. </xsl:when>
  171. <xsl:when test="use-generic">
  172. <xsl:value-of select="use-generic"/>
  173. </xsl:when>
  174. <xsl:otherwise>
  175. <xsl:value-of select="datatype"/><xsl:text>Property.Maker</xsl:text>
  176. </xsl:otherwise>
  177. </xsl:choose>
  178. </xsl:variable>
  179. <!-- Is this property an Enum or derived from a generic Enum -->
  180. <xsl:variable name="enumconst">
  181. <xsl:if test="enumeration/value and not(@type='generic')">
  182. <xsl:text> implements </xsl:text><xsl:value-of select="$eclassname"/></xsl:if>
  183. </xsl:variable>
  184. <redirect:write select="concat('./', $classname, '.java')">
  185. package org.apache.fop.fo.properties;
  186. import java.util.Hashtable;
  187. import org.apache.fop.datatypes.*;
  188. import org.apache.fop.fo.*;
  189. import org.apache.fop.apps.FOPException;
  190. import org.apache.fop.messaging.MessageHandler;
  191. public class <xsl:value-of select="$classname"/> extends <xsl:value-of select="$superclass"/><xsl:value-of select="$enumconst"/> {
  192. <!-- If has enumerated values and is a generic class, create a nested
  193. interface defining the enumeration constants -->
  194. <xsl:if test=".//enumeration and @type='generic'">
  195. public interface Enums {
  196. <xsl:for-each select="enumeration/value">
  197. int <xsl:value-of select="@const"/> = Constants.<xsl:value-of select="@const"/>;
  198. </xsl:for-each>
  199. <xsl:for-each select="compound/subproperty[enumeration]">
  200. <xsl:variable name="spname">
  201. <xsl:call-template name="makeClassName">
  202. <xsl:with-param name="propstr" select="name"/>
  203. </xsl:call-template>
  204. </xsl:variable>
  205. public interface <xsl:value-of select="$spname"/> {
  206. <xsl:for-each select="enumeration/value">
  207. int <xsl:value-of select="@const"/> = Constants.<xsl:value-of select="@const"/>;
  208. </xsl:for-each>
  209. }
  210. </xsl:for-each>
  211. }
  212. </xsl:if>
  213. <!-- Handle enumeration values -->
  214. <xsl:for-each select="enumeration/value">
  215. protected final static EnumProperty s_prop<xsl:value-of select="@const"/> = new EnumProperty(<xsl:if test="../../@type='generic'">Enums.</xsl:if><xsl:value-of select="@const"/>);
  216. </xsl:for-each>
  217. <!-- Look for compound properties -->
  218. <xsl:if test="compound">
  219. <xsl:variable name="enumclass">
  220. <xsl:choose>
  221. <xsl:when test="@type='generic'">Enums</xsl:when>
  222. <xsl:otherwise><xsl:value-of select="$eclassname"/></xsl:otherwise>
  223. </xsl:choose>
  224. </xsl:variable>
  225. <xsl:for-each select="compound/subproperty">
  226. <xsl:variable name="spname">
  227. <xsl:call-template name="makeClassName">
  228. <xsl:with-param name="propstr" select="name"/>
  229. </xsl:call-template>
  230. </xsl:variable>
  231. <xsl:variable name="sp_superclass">
  232. <xsl:choose>
  233. <xsl:when test="use-generic">
  234. <xsl:value-of select="use-generic"/>
  235. </xsl:when>
  236. <xsl:otherwise>
  237. <xsl:value-of select="datatype"/><xsl:text>Property.Maker</xsl:text>
  238. </xsl:otherwise>
  239. </xsl:choose>
  240. </xsl:variable>
  241. <xsl:choose>
  242. <xsl:when test='*[local-name(.)!="name" and local-name(.)!="datatype" and local-name(.)!="use-generic" and local-name(.)!="default"]'>
  243. static private class SP_<xsl:value-of select="$spname"/>Maker
  244. extends <xsl:value-of select="$sp_superclass"/>
  245. <xsl:if test="enumeration"> implements <xsl:value-of select="$enumclass"/>.<xsl:value-of select="$spname"/></xsl:if> {
  246. SP_<xsl:value-of select="$spname"/>Maker(String sPropName) {
  247. super(sPropName);
  248. }
  249. <xsl:for-each select="enumeration/value">
  250. protected final static EnumProperty s_prop<xsl:value-of select="@const"/> = new EnumProperty(<xsl:value-of select="@const"/>);
  251. </xsl:for-each>
  252. <xsl:apply-templates select="percent-ok|auto-ok|keyword-equiv|datatype-conversion|enumeration"/>
  253. }
  254. final private static Property.Maker s_<xsl:value-of select="$spname"/>Maker =
  255. new SP_<xsl:value-of select="$spname"/>Maker(
  256. "<xsl:value-of select='../../name'/>.<xsl:value-of select='name'/>");
  257. </xsl:when>
  258. <xsl:otherwise>
  259. final private static Property.Maker s_<xsl:value-of select="$spname"/>Maker =
  260. new <xsl:value-of select="$sp_superclass"/>(
  261. "<xsl:value-of select='../../name'/>.<xsl:value-of select='name'/>");
  262. </xsl:otherwise>
  263. </xsl:choose>
  264. </xsl:for-each>
  265. </xsl:if>
  266. static public Property.Maker maker(String propName) {
  267. return new <xsl:value-of select="$classname"/>(propName);
  268. }
  269. protected <xsl:value-of select="$classname"/>(String name) {
  270. super(name);
  271. <xsl:if test="compound">
  272. m_shorthandMaker= getSubpropMaker("<xsl:value-of select='compound/subproperty[@set-by-shorthand="true"]/name'/>");
  273. </xsl:if>
  274. }
  275. <xsl:if test="compound">
  276. Property.Maker m_shorthandMaker;
  277. public Property checkEnumValues(String value) {
  278. return m_shorthandMaker.checkEnumValues(value);
  279. }
  280. protected boolean isCompoundMaker() {
  281. return true;
  282. }
  283. protected Property.Maker getSubpropMaker(String subprop) {
  284. <xsl:for-each select="compound/subproperty">
  285. <xsl:variable name="spname">
  286. <xsl:call-template name="makeClassName">
  287. <xsl:with-param name="propstr" select="name"/>
  288. </xsl:call-template>
  289. </xsl:variable>
  290. if (subprop.equals("<xsl:value-of select='name'/>"))
  291. return s_<xsl:value-of select="$spname"/>Maker;
  292. </xsl:for-each>
  293. return super.getSubpropMaker(subprop);
  294. }
  295. protected Property setSubprop(Property baseProp, String subpropName,
  296. Property subProp) {
  297. <xsl:value-of select="datatype"/> val = baseProp.get<xsl:value-of select="datatype"/>();
  298. // Do some type checking???
  299. // Check if one of our subproperties???
  300. val.setComponent(subpropName, subProp, false);
  301. return baseProp;
  302. }
  303. public Property getSubpropValue(Property baseProp, String subpropName) {
  304. <xsl:value-of select="datatype"/> val = baseProp.get<xsl:value-of select="datatype"/>();
  305. return val.getComponent(subpropName);
  306. }
  307. <xsl:choose>
  308. <!-- some subproperty default is context dependent; don't cache default! -->
  309. <xsl:when test='.//default[@contextdep="true"]'>
  310. public Property make(PropertyList propertyList) throws FOPException {
  311. return makeCompound(propertyList, propertyList.getParentFObj());
  312. }
  313. </xsl:when>
  314. <xsl:otherwise>
  315. private Property m_defaultProp=null;
  316. public Property make(PropertyList propertyList) throws FOPException {
  317. if (m_defaultProp == null) {
  318. m_defaultProp=makeCompound(propertyList, propertyList.getParentFObj());
  319. }
  320. return m_defaultProp;
  321. }
  322. </xsl:otherwise>
  323. </xsl:choose>
  324. protected Property makeCompound(PropertyList pList, FObj fo) throws FOPException {
  325. <xsl:value-of select="datatype"/> p = new <xsl:value-of select="datatype"/>();
  326. Property subProp;
  327. <xsl:for-each select="compound/subproperty/name">
  328. <xsl:variable name="spname">
  329. <xsl:call-template name="makeClassName">
  330. <xsl:with-param name="propstr" select="."/>
  331. </xsl:call-template>
  332. </xsl:variable>
  333. // set default for subprop <xsl:value-of select="."/>
  334. subProp = getSubpropMaker("<xsl:value-of select='.'/>").make(pList,
  335. getDefaultFor<xsl:value-of select='$spname'/>(), fo);
  336. p.setComponent("<xsl:value-of select='.'/>", subProp, true);
  337. </xsl:for-each>
  338. return new <xsl:value-of select="$propclass"/>(p);
  339. }
  340. <!-- generate a "getDefaultForXXX" for each subproperty XXX -->
  341. <xsl:for-each select="compound/subproperty">
  342. <xsl:variable name="spname">
  343. <xsl:call-template name="makeClassName">
  344. <xsl:with-param name="propstr" select="name"/>
  345. </xsl:call-template>
  346. </xsl:variable>
  347. protected String getDefaultFor<xsl:value-of select='$spname'/>() {
  348. <xsl:choose><xsl:when test="default">
  349. return "<xsl:value-of select='default'/>";
  350. </xsl:when><xsl:when test="use-generic and key('genericref', use-generic)/default">
  351. return "<xsl:value-of select='key(&apos;genericref&apos;, use-generic)/default'/>";
  352. </xsl:when><xsl:otherwise>
  353. return "";
  354. </xsl:otherwise>
  355. </xsl:choose>
  356. }
  357. </xsl:for-each>
  358. /** Set the appropriate components when the "base" property is set. */
  359. public Property convertProperty(Property p, PropertyList pList,FObj fo)
  360. throws FOPException
  361. {
  362. if (p instanceof <xsl:value-of select="$propclass"/>) return p;
  363. if (! (p instanceof EnumProperty)) {
  364. // delegate to the subprop maker to do conversions
  365. p = m_shorthandMaker.convertProperty(p,pList,fo);
  366. }
  367. if (p != null) {
  368. Property prop = makeCompound(pList, fo);
  369. <xsl:value-of select="datatype"/> pval = prop.get<xsl:value-of select="datatype"/>();
  370. <xsl:for-each select="compound/subproperty[@set-by-shorthand='true']">
  371. pval.setComponent("<xsl:value-of select='name'/>", p, false);
  372. </xsl:for-each>
  373. return prop;
  374. }
  375. else return null;
  376. <!--
  377. else {
  378. // throw some kind of exception!
  379. throw new FOPException("Can't convert value to <xsl:value-of select='$spdt'/> type");
  380. }
  381. -->
  382. }
  383. </xsl:if> <!-- property/compound -->
  384. <xsl:if test="inherited">
  385. public boolean isInherited() { return <xsl:value-of select="inherited"/>; }
  386. </xsl:if>
  387. <!-- the default implementation returns false -->
  388. <xsl:if test='inherited/@type="specified"'>
  389. public boolean inheritsSpecified() {
  390. return true;
  391. }
  392. </xsl:if>
  393. <!-- Currently only works for Enum values -->
  394. <xsl:if test="derive">
  395. public Property compute(PropertyList propertyList) {
  396. Property computedProperty = null;
  397. Property correspondingProperty = propertyList.get("<xsl:value-of select="derive/@from"/>");
  398. if (correspondingProperty != null) {
  399. int correspondingValue = correspondingProperty.getEnum();
  400. <xsl:for-each select="derive/if">
  401. if (correspondingValue == <xsl:value-of select="@match"/>)
  402. computedProperty = new EnumProperty(<xsl:value-of select="."/>);
  403. else</xsl:for-each>
  404. ;
  405. }
  406. return computedProperty;
  407. }
  408. </xsl:if>
  409. <!-- If any corresponding element at property or subproperty levels -->
  410. <xsl:if test=".//corresponding">
  411. <xsl:if test=".//corresponding/@use-if-specified='true'">
  412. public boolean isCorrespondingForced(PropertyList propertyList) {
  413. StringBuffer sbExpr=new StringBuffer();
  414. <xsl:for-each select=".//corresponding/propval">
  415. sbExpr.setLength(0);
  416. <xsl:apply-templates select="."/>
  417. if (propertyList.getExplicit(sbExpr.toString()) != null) return true;
  418. </xsl:for-each>
  419. return false;
  420. }
  421. </xsl:if>
  422. public Property compute(PropertyList propertyList) throws FOPException {
  423. FObj parentFO = propertyList.getParentFObj();
  424. StringBuffer sbExpr=new StringBuffer();
  425. Property p=null;
  426. <xsl:choose><xsl:when test="corresponding/propexpr">
  427. <xsl:apply-templates select="corresponding/propval"/>
  428. // Make sure the property is set before calculating it!
  429. if (propertyList.getExplicitOrShorthand(sbExpr.toString()) == null) return p;
  430. sbExpr.setLength(0);
  431. <xsl:apply-templates select="corresponding/propexpr"/>
  432. p= make(propertyList, sbExpr.toString(), propertyList.getParentFObj());
  433. </xsl:when><xsl:otherwise>
  434. <xsl:apply-templates select="corresponding/propval"/>
  435. p= propertyList.getExplicitOrShorthand(sbExpr.toString());
  436. </xsl:otherwise></xsl:choose>
  437. if (p != null) {
  438. p = convertProperty(p, propertyList, parentFO );
  439. }
  440. <xsl:if test="compound">
  441. else p= makeCompound(propertyList, parentFO);
  442. Property subprop;
  443. <xsl:for-each select="compound/subproperty/corresponding">
  444. sbExpr.setLength(0);
  445. <xsl:choose><xsl:when test="propexpr">
  446. <xsl:apply-templates select="propexpr"/>
  447. subprop= getSubpropMaker("<xsl:value-of select='../name'/>").
  448. make(propertyList, sbExpr.toString(), parentFO);
  449. </xsl:when><xsl:otherwise>
  450. <xsl:apply-templates select="propval"/>
  451. subprop= propertyList.getExplicitOrShorthand(sbExpr.toString());
  452. </xsl:otherwise></xsl:choose>
  453. if (subprop != null) {
  454. setSubprop(p, "<xsl:value-of select='../name'/>", subprop);
  455. }
  456. </xsl:for-each>
  457. </xsl:if>
  458. return p;
  459. }
  460. </xsl:if>
  461. <!-- If can be specified by any shorthand property -->
  462. <xsl:if test="shorthand">
  463. public Property getShorthand(PropertyList propertyList) {
  464. Property p = null;
  465. ListProperty listprop;
  466. <xsl:for-each select="shorthand">
  467. <xsl:variable name="shprop" select="."/>
  468. if (p == null) {
  469. listprop = (ListProperty)propertyList.getExplicit("<xsl:value-of select='$shprop'/>");
  470. if (listprop != null) {
  471. // Get a parser for the shorthand to set the individual properties
  472. ShorthandParser shparser = new <xsl:value-of select="key('shorthandref', $shprop)/datatype-parser"/>(listprop);
  473. p = shparser.getValueForProperty(getPropName(), this, propertyList);
  474. }
  475. }
  476. </xsl:for-each>
  477. return p;
  478. }
  479. </xsl:if>
  480. <xsl:apply-templates select="percent-ok|auto-ok|default|keyword-equiv|datatype-conversion|enumeration|extfile"/>
  481. }
  482. </redirect:write>
  483. </xsl:if> <!-- need to create a class -->
  484. </xsl:template>
  485. <xsl:template match="corresponding/propexpr/propval">
  486. sbExpr.append("_fop-property-value("); <!-- Note: interpreted by property parser -->
  487. <xsl:apply-templates/>
  488. sbExpr.append(")");
  489. </xsl:template>
  490. <xsl:template match="corresponding//text()">
  491. <xsl:variable name="tval" select='normalize-space(.)'/>
  492. <xsl:if test="$tval != ''">sbExpr.append("<xsl:value-of select='$tval'/>");</xsl:if>
  493. </xsl:template>
  494. <xsl:template match="propval/wmrel2abs">
  495. sbExpr.append(propertyList.wmRelToAbs(PropertyList.<xsl:value-of select="@dir"/>));
  496. </xsl:template>
  497. <xsl:template match="propval/wmabs2rel">
  498. sbExpr.append(propertyList.wmAbsToRel(PropertyList.<xsl:value-of select="@dir"/>));
  499. </xsl:template>
  500. <!-- avoid unwanted output to placeholder file -->
  501. <xsl:template match="localname"/>
  502. <!-- Check that each member of the nodeset dtlist has the same value.
  503. Print a message if any member of dtlist is different
  504. from the first member. Return the first member.
  505. -->
  506. <xsl:template name="check-subprop-datatype">
  507. <xsl:param name="dtlist"/>
  508. <xsl:variable name="dt"><xsl:value-of select='$dtlist[1]'/></xsl:variable>
  509. <xsl:for-each select="$dtlist">
  510. <xsl:if test=". != $dt">
  511. <xsl:message>
  512. <xsl:text>Conflict between subproperty datatypes: </xsl:text>
  513. <xsl:value-of select='.'/> != <xsl:value-of select='$dt'/>
  514. </xsl:message>
  515. </xsl:if>
  516. </xsl:for-each>
  517. <xsl:value-of select='$dt'/>
  518. </xsl:template>
  519. <!-- If the value of an enumeration constant contains two or more words,
  520. separated by a blank, map all of these words to the same constant.
  521. -->
  522. <xsl:template name="enumvals">
  523. <xsl:param name="specvals"/>
  524. <xsl:if test='string-length($specvals)>0'>
  525. <xsl:variable name="oneval" select="substring-before($specvals, ' ')"/>
  526. if (value.equals("<xsl:value-of select="$oneval"/>")) { return s_prop<xsl:value-of select="@const"/>; }
  527. <xsl:call-template name="enumvals">
  528. <xsl:with-param name="specvals" select="substring-after($specvals, ' ')"/>
  529. </xsl:call-template>
  530. </xsl:if>
  531. </xsl:template>
  532. </xsl:stylesheet>