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.

propinc.xsl 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <!-- $Id$ -->
  16. <xsl:stylesheet version="1.0"
  17. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  18. <xsl:key name="genericref" match="property[@type='generic']" use="class-name"/>
  19. <xsl:key name="shorthandref" match="property" use="name"/>
  20. <xsl:template name="capfirst">
  21. <xsl:param name="str"/>
  22. <xsl:variable name="lcletters" select="'abcdefghijklmnopqrstuvwxyz'" />
  23. <xsl:variable name="ucletters" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
  24. <xsl:value-of select="concat(translate(substring($str, 1, 1),
  25. $lcletters, $ucletters), substring($str, 2))"/>
  26. </xsl:template>
  27. <xsl:template name="makeClassName">
  28. <xsl:param name="propstr"/>
  29. <xsl:choose>
  30. <xsl:when test="contains($propstr, '-')">
  31. <xsl:call-template name="capfirst">
  32. <xsl:with-param name="str" select="substring-before($propstr, '-')"/>
  33. </xsl:call-template>
  34. <xsl:call-template name="makeClassName">
  35. <xsl:with-param name="propstr" select="substring-after($propstr, '-')"/>
  36. </xsl:call-template>
  37. </xsl:when>
  38. <xsl:otherwise>
  39. <xsl:call-template name="capfirst">
  40. <xsl:with-param name="str" select="$propstr"/>
  41. </xsl:call-template>
  42. </xsl:otherwise>
  43. </xsl:choose>
  44. </xsl:template>
  45. <!-- Generate enumeration constants for FO's, Properties, etc. -->
  46. <xsl:template name="makeEnumConstant">
  47. <xsl:param name="propstr"/>
  48. <xsl:variable name="lcletters" select="'abcdefghijklmnopqrstuvwxyz-:'" />
  49. <xsl:variable name="ucletters" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ__'" />
  50. <xsl:value-of select="translate($propstr, $lcletters, $ucletters)"/>
  51. </xsl:template>
  52. <!-- The name of the subclass of Property to be created -->
  53. <xsl:template name="propclass">
  54. <xsl:param name="prop" select="."/>
  55. <xsl:choose>
  56. <xsl:when test="$prop/datatype">
  57. <xsl:value-of select="$prop/datatype"/><xsl:text>Property</xsl:text>
  58. </xsl:when>
  59. <xsl:when test="$prop/use-generic[@ispropclass='true']">
  60. <xsl:value-of select="$prop/use-generic"/>
  61. </xsl:when>
  62. <xsl:when test="$prop/use-generic">
  63. <!-- If no datatype child, then the prop must use the same datatype as
  64. its template. -->
  65. <xsl:call-template name="propclass">
  66. <xsl:with-param name="prop"
  67. select="key('genericref', $prop/use-generic)"/>
  68. </xsl:call-template>
  69. </xsl:when>
  70. <xsl:otherwise>
  71. <!-- ERROR -->
  72. <xsl:message terminate="yes">
  73. No datatype found for property: <xsl:value-of select="$prop/name"/>
  74. </xsl:message>
  75. </xsl:otherwise>
  76. </xsl:choose>
  77. </xsl:template>
  78. <!-- return a boolean value -->
  79. <xsl:template name="hasEnum">
  80. <xsl:param name="prop" select="."/>
  81. <xsl:choose>
  82. <xsl:when test="$prop/enumeration">true</xsl:when>
  83. <xsl:when test="$prop/use-generic">
  84. <!-- If no datatype child, then the prop must use the same datatype as
  85. its template. -->
  86. <xsl:call-template name="hasEnum">
  87. <xsl:with-param name="prop"
  88. select="key('genericref', $prop/use-generic)"/>
  89. </xsl:call-template>
  90. </xsl:when>
  91. <xsl:otherwise>false</xsl:otherwise>
  92. </xsl:choose>
  93. </xsl:template>
  94. <!-- return a boolean value -->
  95. <xsl:template name="hasSubpropEnum">
  96. <xsl:param name="prop" select="."/>
  97. <xsl:choose>
  98. <xsl:when test="$prop/compound/subproperty/enumeration">true</xsl:when>
  99. <xsl:when test="$prop/use-generic">
  100. <!-- If no datatype child, then the prop must use the same datatype as
  101. its template. -->
  102. <xsl:call-template name="hasSubpropEnum">
  103. <xsl:with-param name="prop"
  104. select="key('genericref', $prop/use-generic)"/>
  105. </xsl:call-template>
  106. </xsl:when>
  107. <xsl:when test="$prop/compound/subproperty/use-generic">
  108. <xsl:for-each select="$prop/compound/subproperty[use-generic]">
  109. <xsl:call-template name="hasEnum">
  110. <xsl:with-param name="prop"
  111. select="key('genericref', use-generic)"/>
  112. </xsl:call-template>
  113. </xsl:for-each>
  114. </xsl:when>
  115. <xsl:otherwise>false</xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:template>
  118. </xsl:stylesheet>