1
0

dbs3-upgrade.xsl 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?xml version="1.0" encoding="ASCII"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns="http://docbook.org/ns/docbook"
  4. xmlns:dbs="http://docbook.org/ns/docbook-slides"
  5. xmlns:xlink="http://www.w3.org/1999/xlink"
  6. version="1.0">
  7. <xsl:output method="xml" encoding="utf-8" indent="no"/>
  8. <xsl:preserve-space elements="*"/>
  9. <xsl:template match="/slides">
  10. <dbs:slides>
  11. <xsl:call-template name="process.content"/>
  12. </dbs:slides>
  13. </xsl:template>
  14. <xsl:template name="process.content">
  15. <xsl:apply-templates select="slidesinfo|foilgroupinfo|foilinfo|title|titleabbrev|subtitle"/>
  16. <xsl:apply-templates select="speakernotes"/>
  17. <xsl:apply-templates select="*[not(self::speakernotes)][not(self::title)][not(self::titleabbrev)][not(self::subtitle)][not(self::slidesinfo)][not(self::foilinfo)][not(self::foilgroupinfo)]"/>
  18. </xsl:template>
  19. <xsl:template match="foil">
  20. <dbs:foil>
  21. <xsl:call-template name="copy.attributes"/>
  22. <xsl:call-template name="process.content"/>
  23. </dbs:foil>
  24. </xsl:template>
  25. <xsl:template match="foilgroup">
  26. <dbs:foilgroup>
  27. <xsl:call-template name="copy.attributes"/>
  28. <xsl:call-template name="process.content"/>
  29. </dbs:foilgroup>
  30. </xsl:template>
  31. <xsl:template match="speakernotes">
  32. <dbs:speakernotes>
  33. <xsl:call-template name="copy.attributes"/>
  34. <xsl:apply-templates select="*"/>
  35. </dbs:speakernotes>
  36. </xsl:template>
  37. <xsl:template match="slidesinfo|foilgroupinfo|foilinfo">
  38. <info>
  39. <xsl:call-template name="copy.attributes"/>
  40. <xsl:apply-templates select="*"/>
  41. </info>
  42. </xsl:template>
  43. <!-- ******************************************************************
  44. DB4 -> DB5 related, adapted from db4-upgrade.xsl
  45. ****************************************************************** -->
  46. <xsl:template name="copy.attributes">
  47. <xsl:param name="suppress" select="''"/>
  48. <xsl:for-each select="@*">
  49. <xsl:choose>
  50. <xsl:when test="local-name(.) = 'lang'">
  51. <xsl:attribute name="xml:lang">
  52. <xsl:value-of select="."/>
  53. </xsl:attribute>
  54. </xsl:when>
  55. <xsl:when test="local-name(.) = 'id'">
  56. <xsl:attribute name="xml:id">
  57. <xsl:value-of select="."/>
  58. </xsl:attribute>
  59. </xsl:when>
  60. <xsl:when test="local-name(.) = 'moreinfo'"/>
  61. <xsl:when test="$suppress = local-name(.)"/>
  62. <xsl:otherwise>
  63. <xsl:copy/>
  64. </xsl:otherwise>
  65. </xsl:choose>
  66. </xsl:for-each>
  67. </xsl:template>
  68. <xsl:template match="*">
  69. <xsl:element name="{local-name()}" namespace="http://docbook.org/ns/docbook">
  70. <xsl:call-template name="copy.attributes"/>
  71. <xsl:apply-templates />
  72. </xsl:element>
  73. </xsl:template>
  74. <xsl:template match="author[not(personname)]|editor[not(personname)]|othercredit[not(personname)]">
  75. <xsl:element name="{local-name()}" namespace="http://docbook.org/ns/docbook">
  76. <xsl:call-template name="copy.attributes"/>
  77. <personname>
  78. <xsl:apply-templates select="honorific|firstname|surname|othername|lineage"/>
  79. </personname>
  80. <xsl:apply-templates select="*[not(self::honorific|self::firstname|self::surname
  81. |self::othername|self::lineage)]"/>
  82. </xsl:element>
  83. </xsl:template>
  84. <xsl:template match="address|programlisting|screen|funcsynopsisinfo
  85. |classsynopsisinfo|literallayout">
  86. <xsl:element name="{local-name()}" namespace="http://docbook.org/ns/docbook">
  87. <xsl:call-template name="copy.attributes">
  88. <xsl:with-param name="suppress" select="'format'"/>
  89. </xsl:call-template>
  90. <xsl:apply-templates/>
  91. </xsl:element>
  92. </xsl:template>
  93. <xsl:template match="inlinegraphic[@format='linespecific']">
  94. <textobject>
  95. <textdata>
  96. <xsl:call-template name="copy.attributes"/>
  97. </textdata>
  98. </textobject>
  99. </xsl:template>
  100. <xsl:template match="inlinegraphic">
  101. <inlinemediaobject>
  102. <imageobject>
  103. <imagedata>
  104. <xsl:call-template name="copy.attributes"/>
  105. </imagedata>
  106. </imageobject>
  107. </inlinemediaobject>
  108. </xsl:template>
  109. <xsl:template match="graphic[@format='linespecific']">
  110. <mediaobject>
  111. <textobject>
  112. <textdata>
  113. <xsl:call-template name="copy.attributes"/>
  114. </textdata>
  115. </textobject>
  116. </mediaobject>
  117. </xsl:template>
  118. <xsl:template match="graphic">
  119. <mediaobject>
  120. <imageobject>
  121. <imagedata>
  122. <xsl:call-template name="copy.attributes"/>
  123. </imagedata>
  124. </imageobject>
  125. </mediaobject>
  126. </xsl:template>
  127. <xsl:template match="ulink" priority="200">
  128. <xsl:choose>
  129. <xsl:when test="node()">
  130. <link xlink:href="{@url}">
  131. <xsl:call-template name="copy.attributes">
  132. <xsl:with-param name="suppress" select="'url'"/>
  133. </xsl:call-template>
  134. <xsl:apply-templates/>
  135. </link>
  136. </xsl:when>
  137. <xsl:otherwise>
  138. <uri xlink:href="{@url}">
  139. <xsl:call-template name="copy.attributes">
  140. <xsl:with-param name="suppress" select="'url'"/>
  141. </xsl:call-template>
  142. <xsl:value-of select="@url"/>
  143. </uri>
  144. </xsl:otherwise>
  145. </xsl:choose>
  146. </xsl:template>
  147. <xsl:template match="*[namespace-uri()]">
  148. <xsl:copy-of select="."/>
  149. </xsl:template>
  150. </xsl:stylesheet>