root-processing_fop.xsl 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  5. xmlns:x="adobe:ns:meta/"
  6. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  7. xmlns:dc="http://purl.org/dc/elements/1.1/"
  8. xmlns:xmp="http://ns.adobe.com/xap/1.0/"
  9. xmlns:pdf="http://ns.adobe.com/pdf/1.3/"
  10. xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
  11. version="2.0" exclude-result-prefixes="dita-ot xs">
  12. <xsl:template match="/" name="rootTemplate">
  13. <xsl:call-template name="validateTopicRefs"/>
  14. <fo:root xsl:use-attribute-sets="__fo__root">
  15. <xsl:call-template name="createLayoutMasters"/>
  16. <xsl:call-template name="createMetadata"/>
  17. <xsl:call-template name="createBookmarks"/>
  18. <xsl:apply-templates select="*" mode="generatePageSequences"/>
  19. </fo:root>
  20. </xsl:template>
  21. <xsl:template match="document-node()[*[contains(@class, ' topic/topic ')]]">
  22. <fo:root xsl:use-attribute-sets="__fo__root">
  23. <xsl:call-template name="createLayoutMasters"/>
  24. <xsl:call-template name="createMetadata"/>
  25. <xsl:call-template name="createBookmarks"/>
  26. <xsl:apply-templates/>
  27. </fo:root>
  28. </xsl:template>
  29. <xsl:template name="createMetadata">
  30. <fo:declarations>
  31. <x:xmpmeta>
  32. <rdf:RDF>
  33. <rdf:Description rdf:about="">
  34. <xsl:variable name="title" as="xs:string?">
  35. <xsl:apply-templates select="." mode="dita-ot:title-metadata"/>
  36. </xsl:variable>
  37. <xsl:if test="exists($title)">
  38. <dc:title>
  39. <xsl:value-of select="$title"/>
  40. </dc:title>
  41. </xsl:if>
  42. <xsl:variable name="author" as="xs:string?">
  43. <xsl:apply-templates select="." mode="dita-ot:author-metadata"/>
  44. </xsl:variable>
  45. <xsl:if test="exists($author)">
  46. <dc:creator>
  47. <xsl:value-of select="$author"/>
  48. </dc:creator>
  49. </xsl:if>
  50. <xsl:variable name="keywords" as="xs:string*">
  51. <xsl:apply-templates select="." mode="dita-ot:keywords-metadata"/>
  52. </xsl:variable>
  53. <xsl:if test="exists($keywords)">
  54. <pdf:Keywords>
  55. <xsl:value-of select="$keywords" separator=", "/>
  56. </pdf:Keywords>
  57. </xsl:if>
  58. <xsl:variable name="subject" as="xs:string?">
  59. <xsl:apply-templates select="." mode="dita-ot:subject-metadata"/>
  60. </xsl:variable>
  61. <xsl:if test="exists($subject)">
  62. <dc:description>
  63. <rdf:Alt>
  64. <rdf:li xml:lang="x-default">
  65. <xsl:value-of select="$subject"/>
  66. </rdf:li>
  67. </rdf:Alt>
  68. </dc:description>
  69. </xsl:if>
  70. <xmp:CreatorTool>DITA Open Toolkit</xmp:CreatorTool>
  71. </rdf:Description>
  72. </rdf:RDF>
  73. </x:xmpmeta>
  74. </fo:declarations>
  75. </xsl:template>
  76. </xsl:stylesheet>