dita2xhtml-util.xsl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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
  4. applicable licenses.-->
  5. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  6. version="2.0">
  7. <xsl:template match="/">
  8. <xsl:variable name="content" as="node()*">
  9. <xsl:apply-imports/>
  10. </xsl:variable>
  11. <xsl:apply-templates select="$content" mode="add-xhtml-ns"/>
  12. </xsl:template>
  13. <xsl:template match="*[namespace-uri() eq '']" mode="add-xhtml-ns" priority="10">
  14. <xsl:element name="{name()}" namespace="http://www.w3.org/1999/xhtml">
  15. <xsl:apply-templates select="@* | node()" mode="add-xhtml-ns"/>
  16. </xsl:element>
  17. </xsl:template>
  18. <xsl:template match="nav | section | figure | article" mode="add-xhtml-ns" priority="20">
  19. <xsl:element name="div" namespace="http://www.w3.org/1999/xhtml">
  20. <xsl:apply-templates select="@* except @role | node()" mode="add-xhtml-ns"/>
  21. </xsl:element>
  22. </xsl:template>
  23. <!-- Group for root document node does not need extra XHTML div -->
  24. <xsl:template match="main/article" mode="add-xhtml-ns" priority="30">
  25. <xsl:apply-templates select="node()" mode="add-xhtml-ns"/>
  26. </xsl:template>
  27. <xsl:template match="header | footer | main" mode="add-xhtml-ns" priority="20">
  28. <xsl:apply-templates select="node()" mode="add-xhtml-ns"/>
  29. </xsl:template>
  30. <xsl:template match="div/@role" mode="add-xhtml-ns" priority="10"/>
  31. <xsl:template match="@*[starts-with(name(), 'data-')]" mode="add-xhtml-ns" priority="10"/>
  32. <xsl:template match="@* | node()" mode="add-xhtml-ns">
  33. <xsl:copy>
  34. <xsl:apply-templates select="@* | node()" mode="add-xhtml-ns"/>
  35. </xsl:copy>
  36. </xsl:template>
  37. </xsl:stylesheet>