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 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  3. <xsl:key name="genericref" match="property[@type='generic']" use="class-name"/>
  4. <xsl:key name="shorthandref" match="property" use="name"/>
  5. <xsl:template name="capfirst">
  6. <xsl:param name="str"/>
  7. <xsl:variable name="lcletters" select="'abcdefghijklmnopqrstuvwxyz'" />
  8. <xsl:variable name="ucletters" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
  9. <xsl:value-of select="concat(translate(substring($str, 1, 1),
  10. $lcletters, $ucletters), substring($str, 2))"/>
  11. </xsl:template>
  12. <xsl:template name="makeClassName">
  13. <xsl:param name="propstr"/>
  14. <xsl:choose>
  15. <xsl:when test="contains($propstr, '-')">
  16. <xsl:call-template name="capfirst">
  17. <xsl:with-param name="str" select="substring-before($propstr, '-')"/>
  18. </xsl:call-template>
  19. <xsl:call-template name="makeClassName">
  20. <xsl:with-param name="propstr" select="substring-after($propstr, '-')"/>
  21. </xsl:call-template>
  22. </xsl:when>
  23. <xsl:otherwise>
  24. <xsl:call-template name="capfirst">
  25. <xsl:with-param name="str" select="$propstr"/>
  26. </xsl:call-template>
  27. </xsl:otherwise>
  28. </xsl:choose>
  29. </xsl:template>
  30. <!-- The name of the subclass of Property to be created -->
  31. <xsl:template name="propclass">
  32. <xsl:param name="prop" select="."/>
  33. <xsl:choose>
  34. <xsl:when test="$prop/datatype">
  35. <xsl:value-of select="$prop/datatype"/><xsl:text>Property</xsl:text>
  36. </xsl:when>
  37. <xsl:when test="$prop/use-generic[@ispropclass='true']">
  38. <xsl:value-of select="$prop/use-generic"/>
  39. </xsl:when>
  40. <xsl:when test="$prop/use-generic">
  41. <!-- If no datatype child, then the prop must use the same datatype as
  42. its template. -->
  43. <xsl:call-template name="propclass">
  44. <xsl:with-param name="prop"
  45. select="key('genericref', $prop/use-generic)"/>
  46. </xsl:call-template>
  47. </xsl:when>
  48. <xsl:otherwise>
  49. <!-- ERROR -->
  50. <xsl:message terminate="yes">
  51. No datatype found for property: <xsl:value-of select="$prop/name"/>
  52. </xsl:message>
  53. </xsl:otherwise>
  54. </xsl:choose>
  55. </xsl:template>
  56. <!-- return a boolean value -->
  57. <xsl:template name="hasEnum">
  58. <xsl:param name="prop" select="."/>
  59. <xsl:choose>
  60. <xsl:when test="$prop/enumeration">true</xsl:when>
  61. <xsl:when test="$prop/use-generic">
  62. <!-- If no datatype child, then the prop must use the same datatype as
  63. its template. -->
  64. <xsl:call-template name="hasEnum">
  65. <xsl:with-param name="prop"
  66. select="key('genericref', $prop/use-generic)"/>
  67. </xsl:call-template>
  68. </xsl:when>
  69. <xsl:otherwise>false</xsl:otherwise>
  70. </xsl:choose>
  71. </xsl:template>
  72. <!-- return a boolean value -->
  73. <xsl:template name="hasSubpropEnum">
  74. <xsl:param name="prop" select="."/>
  75. <xsl:choose>
  76. <xsl:when test="$prop/compound/subproperty/enumeration">true</xsl:when>
  77. <xsl:when test="$prop/use-generic">
  78. <!-- If no datatype child, then the prop must use the same datatype as
  79. its template. -->
  80. <xsl:call-template name="hasSubpropEnum">
  81. <xsl:with-param name="prop"
  82. select="key('genericref', $prop/use-generic)"/>
  83. </xsl:call-template>
  84. </xsl:when>
  85. <xsl:when test="$prop/compound/subproperty/use-generic">
  86. <xsl:for-each select="$prop/compound/subproperty[use-generic]">
  87. <xsl:call-template name="hasEnum">
  88. <xsl:with-param name="prop"
  89. select="key('genericref', use-generic)"/>
  90. </xsl:call-template>
  91. </xsl:for-each>
  92. </xsl:when>
  93. <xsl:otherwise>false</xsl:otherwise>
  94. </xsl:choose>
  95. </xsl:template>
  96. </xsl:stylesheet>