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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <transform xmlns="http://www.w3.org/1999/XSL/Transform"
  2. xmlns:xt="http://www.jclark.com/xt" element-prefixes="xt"
  3. version="1.0">
  4. <template match="property" priority="-1">
  5. <variable name="classname" select="class-name"/>
  6. <xt:document method="text" href="org/apache/xml/fop/fo/properties/{$classname}.java">
  7. package org.apache.xml.fop.fo.properties;
  8. import org.apache.xml.fop.datatypes.*;
  9. import org.apache.xml.fop.fo.*;
  10. import org.apache.xml.fop.apps.FOPException;
  11. public class <value-of select="class-name"/> extends Property {
  12. public static class Maker extends Property.Maker {
  13. public boolean isInherited() { return <value-of select="inherited"/>; }
  14. public Property make(PropertyList propertyList, String value) throws FOPException {
  15. <choose>
  16. <when test="make">
  17. <variable name="datatype" select="datatype"/>
  18. <value-of select="$datatype"/> v;
  19. <if test="make/to-double">
  20. double d = toDouble(value);
  21. </if>
  22. <for-each select="make/if">
  23. if (value.equals("<value-of select="@match"/>")) {
  24. v = new <value-of select="$datatype"/>(<value-of select="."/>);
  25. }
  26. </for-each>
  27. <for-each select="make/else-if-number">
  28. else if (!Double.isNaN(d)) {
  29. v = new <value-of select="$datatype"/>( <value-of select="."/>);
  30. }
  31. </for-each>
  32. else {
  33. v = new <value-of select="datatype"/>(<value-of select="make/else"/>);
  34. }
  35. return new <value-of select="class-name"/>(propertyList, v);
  36. </when>
  37. <otherwise>
  38. return new <value-of select="class-name"/>(propertyList, new <value-of select="datatype"/>(value));
  39. </otherwise>
  40. </choose>
  41. }
  42. public Property make(PropertyList propertyList) throws FOPException {
  43. return make(propertyList, "<value-of select="default"/>");
  44. }
  45. }
  46. public static Property.Maker maker() {
  47. return new <value-of select="class-name"/>.Maker();
  48. }
  49. private <value-of select="datatype"/> value;
  50. public <value-of select="class-name"/>(PropertyList propertyList, <value-of select="datatype"/> explicitValue) {
  51. this.propertyList = propertyList;
  52. this.value = explicitValue;
  53. }
  54. public <value-of select="datatype"/> get<value-of select="datatype"/>() {
  55. return this.value;
  56. }
  57. }
  58. </xt:document>
  59. </template>
  60. <template match="property[datatype/enumeration]">
  61. <variable name="classname" select="class-name"/>
  62. <xt:document method="text" href="org/apache/xml/fop/fo/properties/{$classname}.java">
  63. package org.apache.xml.fop.fo.properties;
  64. import org.apache.xml.fop.datatypes.*;
  65. import org.apache.xml.fop.fo.*;
  66. import org.apache.xml.fop.apps.FOPException;
  67. public class <value-of select="class-name"/> extends Property {
  68. <for-each select="datatype/enumeration/value">
  69. public final static int <value-of select="@const"/> = <number/>;</for-each>
  70. public static class Maker extends Property.Maker {
  71. public boolean isInherited() { return <value-of select="inherited"/>; }
  72. public Property make(PropertyList propertyList, String value) throws FOPException {
  73. int v;
  74. <for-each select="datatype/enumeration/value">
  75. if (value.equals("<value-of select="."/>")) { v = <value-of select="@const"/>; }
  76. else</for-each>
  77. {
  78. System.err.println("WARNING: Unknown value for <value-of select="name"/>: " + value);
  79. return make(propertyList, "<value-of select="default"/>");
  80. }
  81. return new <value-of select="class-name"/>(propertyList, v);
  82. }
  83. public Property make(PropertyList propertyList) throws FOPException {
  84. return make(propertyList, "<value-of select="default"/>");
  85. }
  86. <if test="derive">
  87. public Property compute(PropertyList propertyList) {
  88. Property computedProperty = null;
  89. Property correspondingProperty = propertyList.get("<value-of select="derive/@from"/>");
  90. if (correspondingProperty != null) {
  91. int correspondingValue = correspondingProperty.getEnum();
  92. <for-each select="derive/if">
  93. if (correspondingValue == <value-of select="@match"/>)
  94. computedProperty = new <value-of select="$classname"/>(propertyList, <value-of select="."/>);
  95. else</for-each>
  96. ;
  97. }
  98. return computedProperty;
  99. }
  100. </if>
  101. }
  102. public static Property.Maker maker() {
  103. return new <value-of select="class-name"/>.Maker();
  104. }
  105. private int value;
  106. public <value-of select="class-name"/>(PropertyList propertyList, int explicitValue) {
  107. this.propertyList = propertyList;
  108. this.value = explicitValue;
  109. }
  110. public int getEnum() {
  111. return this.value;
  112. }
  113. }
  114. </xt:document>
  115. </template>
  116. </transform>