properties.xsl 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- This file is part of the DITA Open Toolkit project.
  3. See the accompanying license.txt file for applicable licenses. -->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  5. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  6. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  7. xmlns:table="http://dita-ot.sourceforge.net/ns/201007/dita-ot/table"
  8. xmlns:simpletable="http://dita-ot.sourceforge.net/ns/201007/dita-ot/simpletable"
  9. version="2.0"
  10. exclude-result-prefixes="xs dita-ot table simpletable">
  11. <xsl:variable name="empty-property" as="element(property)">
  12. <property class="- topic/sthead reference/property ">
  13. <proptype class="- topic/stentry reference/proptype "/>
  14. <propvalue class="- topic/stentry reference/propvalue "/>
  15. <propdesc class="- topic/stentry reference/propdesc "/>
  16. </property>
  17. </xsl:variable>
  18. <xsl:template match="*[contains(@class, ' reference/property ')]">
  19. <xsl:variable name="property" select="." as="element()"/>
  20. <tr>
  21. <xsl:apply-templates select="." mode="table:common"/>
  22. <xsl:for-each select="(' reference/proptype ', ' reference/propvalue ', ' reference/propdesc ')">
  23. <xsl:variable name="class" select="." as="xs:string"/>
  24. <xsl:choose>
  25. <xsl:when test="exists($property/*[contains(@class, $class)])">
  26. <xsl:apply-templates select="$property/*[contains(@class, $class)]"/>
  27. </xsl:when>
  28. <xsl:otherwise>
  29. <xsl:apply-templates select="$empty-property/*[contains(@class, $class)]">
  30. <xsl:with-param name="ctx" select="$property" as="element()" tunnel="yes"/>
  31. </xsl:apply-templates>
  32. </xsl:otherwise>
  33. </xsl:choose>
  34. </xsl:for-each>
  35. </tr>
  36. </xsl:template>
  37. <xsl:template mode="generate-table-header" match="
  38. *[contains(@class,' reference/properties ')]
  39. [empty(*[contains(@class,' reference/prophead ')])]
  40. ">
  41. <prophead class="- topic/sthead reference/prophead ">
  42. <proptypehd class="- topic/stentry task/proptypehd ">
  43. <xsl:attribute name="id" select="simpletable:generate-headers(., 'type')"/>
  44. <xsl:sequence select="dita-ot:get-variable(., 'Type')"/>
  45. </proptypehd>
  46. <propvaluehd class="- topic/stentry task/propvaluehd ">
  47. <xsl:attribute name="id" select="simpletable:generate-headers(., 'value')"/>
  48. <xsl:sequence select="dita-ot:get-variable(., 'Value')"/>
  49. </propvaluehd>
  50. <propdeschd class="- topic/stentry task/propdeschd ">
  51. <xsl:attribute name="id" select="simpletable:generate-headers(., 'desc')"/>
  52. <xsl:sequence select="dita-ot:get-variable(., 'Description')"/>
  53. </propdeschd>
  54. </prophead>
  55. </xsl:template>
  56. <xsl:template mode="headers" match="
  57. *[contains(@class, ' reference/property ')]/*
  58. ">
  59. <xsl:param name="ctx" as="element()" tunnel="yes" select="."/>
  60. <xsl:variable name="table" as="element()" select="
  61. simpletable:get-current-table($ctx)
  62. "/>
  63. <xsl:variable name="name" as="xs:string" select="
  64. substring-after(local-name(), 'prop')
  65. "/>
  66. <xsl:variable name="header" as="element()?" select="
  67. $table/*/*[contains(@class, concat(' reference/prop', $name, 'hd '))]
  68. "/>
  69. <xsl:attribute name="headers" select="
  70. ($header/@id,
  71. generate-id($header),
  72. simpletable:generate-headers($table, $name))[normalize-space(.)][1]
  73. "/>
  74. </xsl:template>
  75. </xsl:stylesheet>