properties.xsl 3.5 KB

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