root-processing_fop.xsl 3.3 KB

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