css-class.xsl 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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. version="2.0"
  8. exclude-result-prefixes="xs dita-ot">
  9. <xsl:function name="dita-ot:css-class" as="xs:string">
  10. <xsl:param name="block-name" as="xs:string?"/>
  11. <xsl:param name="attr" as="attribute()"/>
  12. <xsl:sequence select="
  13. string-join(($block-name, concat(node-name($attr), '-', $attr)), '--')
  14. "/>
  15. </xsl:function>
  16. <xsl:function name="dita-ot:css-class" as="xs:string">
  17. <xsl:param name="attr" as="attribute()"/>
  18. <xsl:sequence select="
  19. dita-ot:css-class(xs:string(node-name($attr/parent::*)), $attr)
  20. "/>
  21. </xsl:function>
  22. <!-- Don't generate CSS classes for any element or attribute by default. -->
  23. <xsl:template match="* | @*" mode="css-class"/>
  24. <!-- Display attributes group -->
  25. <xsl:template match="@frame | @expanse | @scale" mode="css-class">
  26. <xsl:sequence select="dita-ot:css-class((), .)"/>
  27. </xsl:template>
  28. </xsl:stylesheet>