toc.xsl 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="2.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4. xmlns:outline="http://wkhtmltopdf.org/outline"
  5. xmlns="http://www.w3.org/1999/xhtml">
  6. <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  7. doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  8. indent="yes" />
  9. <xsl:template match="outline:outline">
  10. <html>
  11. <head>
  12. <title>Table of Contents</title>
  13. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  14. <style>
  15. h1 {
  16. text-align: center;
  17. font-size: 20px;
  18. font-family: arial;
  19. }
  20. div {border-bottom: 1px dashed rgb(200,200,200);}
  21. span {float: right;}
  22. li {list-style: none;}
  23. ul {
  24. font-size: 20px;
  25. font-family: arial;
  26. }
  27. ul ul {font-size: 80%; }
  28. ul {padding-left: 0em;}
  29. ul ul {padding-left: 1em;}
  30. a {text-decoration:none; color: black;}
  31. </style>
  32. </head>
  33. <body>
  34. <h1>Table of Contents</h1>
  35. <ul><xsl:apply-templates select="outline:item/outline:item"/></ul>
  36. </body>
  37. </html>
  38. </xsl:template>
  39. <xsl:template match="outline:item">
  40. <li>
  41. <xsl:if test="@title!=''">
  42. <div>
  43. <a>
  44. <xsl:if test="@link">
  45. <xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute>
  46. </xsl:if>
  47. <xsl:if test="@backLink">
  48. <xsl:attribute name="name"><xsl:value-of select="@backLink"/></xsl:attribute>
  49. </xsl:if>
  50. <xsl:value-of select="@title" />
  51. </a>
  52. <span> <xsl:value-of select="@page" /> </span>
  53. </div>
  54. </xsl:if>
  55. <ul>
  56. <xsl:comment>added to prevent self-closing tags in QtXmlPatterns</xsl:comment>
  57. <xsl:apply-templates select="outline:item"/>
  58. </ul>
  59. </li>
  60. </xsl:template>
  61. </xsl:stylesheet>