attr-set-reflection.xsl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <?xml version='1.0'?>
  2. <!--
  3. Copyright © 2004-2005 by Idiom Technologies, Inc. All rights reserved.
  4. IDIOM is a registered trademark of Idiom Technologies, Inc. and WORLDSERVER
  5. and WORLDSTART are trademarks of Idiom Technologies, Inc. All other
  6. trademarks are the property of their respective owners.
  7. IDIOM TECHNOLOGIES, INC. IS DELIVERING THE SOFTWARE "AS IS," WITH
  8. ABSOLUTELY NO WARRANTIES WHATSOEVER, WHETHER EXPRESS OR IMPLIED, AND IDIOM
  9. TECHNOLOGIES, INC. DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
  10. BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  11. PURPOSE AND WARRANTY OF NON-INFRINGEMENT. IDIOM TECHNOLOGIES, INC. SHALL NOT
  12. BE LIABLE FOR INDIRECT, INCIDENTAL, SPECIAL, COVER, PUNITIVE, EXEMPLARY,
  13. RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF
  14. ANTICIPATED PROFIT), ARISING FROM ANY CAUSE UNDER OR RELATED TO OR ARISING
  15. OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF IDIOM
  16. TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  17. Idiom Technologies, Inc. and its licensors shall not be liable for any
  18. damages suffered by any person as a result of using and/or modifying the
  19. Software or its derivatives. In no event shall Idiom Technologies, Inc.'s
  20. liability for any damages hereunder exceed the amounts received by Idiom
  21. Technologies, Inc. as a result of this transaction.
  22. These terms and conditions supersede the terms and conditions in any
  23. licensing agreement to the extent that such terms and conditions conflict
  24. with those set forth herein.
  25. This file is part of the DITA Open Toolkit project hosted on Sourceforge.net.
  26. See the accompanying license.txt file for applicable licenses.
  27. -->
  28. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  29. version='2.0'>
  30. <!--
  31. A word of explanation:
  32. The templates in this file are to work around a problem in XSLT. XSLT
  33. requires that attribute sets be addressed by name, and not by a variable.
  34. There are a few places that the plugin generates the name of an attribute
  35. set, and wants to use it anyway. The original version of these templates
  36. provided a very incomplete substitute for standard attribute sets, in that
  37. they didn't allow any XSLT constructions within the attributes, and they
  38. didn't find attribute sets imported by the custom files.
  39. The current version now falls back to the old implementation, but first
  40. checks a list of possible attribute-sets, and uses attribute-sets on the
  41. list just like regular named attribute sets.
  42. -->
  43. <xsl:template name="new-attr-set-reflection">
  44. <xsl:param name="temp-element" />
  45. <xsl:for-each select="$temp-element//@*">
  46. <xsl:attribute name="{name()}">
  47. <xsl:value-of select="."/>
  48. </xsl:attribute>
  49. </xsl:for-each>
  50. </xsl:template>
  51. <xsl:template name="processAttrSetReflection">
  52. <xsl:param name="attrSet"/>
  53. <xsl:param name="path"/>
  54. <xsl:choose>
  55. <xsl:when test="$attrSet = 'topic.title'">
  56. <xsl:call-template name="new-attr-set-reflection">
  57. <xsl:with-param name="temp-element">
  58. <xsl:element name="placeholder" use-attribute-sets="topic.title"/>
  59. </xsl:with-param>
  60. </xsl:call-template>
  61. </xsl:when>
  62. <xsl:when test="$attrSet = 'topic.topic.title'">
  63. <xsl:call-template name="new-attr-set-reflection">
  64. <xsl:with-param name="temp-element">
  65. <xsl:element name="placeholder" use-attribute-sets="topic.topic.title"/>
  66. </xsl:with-param>
  67. </xsl:call-template>
  68. </xsl:when>
  69. <xsl:when test="$attrSet = 'topic.topic.topic.title'">
  70. <xsl:call-template name="new-attr-set-reflection">
  71. <xsl:with-param name="temp-element">
  72. <xsl:element name="placeholder" use-attribute-sets="topic.topic.topic.title"/>
  73. </xsl:with-param>
  74. </xsl:call-template>
  75. </xsl:when>
  76. <xsl:when test="$attrSet = 'topic.topic.topic.topic.title'">
  77. <xsl:call-template name="new-attr-set-reflection">
  78. <xsl:with-param name="temp-element">
  79. <xsl:element name="placeholder" use-attribute-sets="topic.topic.topic.topic.title"/>
  80. </xsl:with-param>
  81. </xsl:call-template>
  82. </xsl:when>
  83. <xsl:when test="$attrSet = 'topic.topic.topic.topic.topic.title'">
  84. <xsl:call-template name="new-attr-set-reflection">
  85. <xsl:with-param name="temp-element">
  86. <xsl:element name="placeholder" use-attribute-sets="topic.topic.topic.topic.topic.title"/>
  87. </xsl:with-param>
  88. </xsl:call-template>
  89. </xsl:when>
  90. <xsl:when test="$attrSet = 'topic.topic.topic.topic.topic.topic.title'">
  91. <xsl:call-template name="new-attr-set-reflection">
  92. <xsl:with-param name="temp-element">
  93. <xsl:element name="placeholder" use-attribute-sets="topic.topic.topic.topic.topic.topic.title"/>
  94. </xsl:with-param>
  95. </xsl:call-template>
  96. </xsl:when>
  97. <xsl:when test="$attrSet = '__tableframe__bottom'">
  98. <xsl:call-template name="new-attr-set-reflection">
  99. <xsl:with-param name="temp-element">
  100. <xsl:element name="placeholder" use-attribute-sets="__tableframe__bottom"/>
  101. </xsl:with-param>
  102. </xsl:call-template>
  103. </xsl:when>
  104. <xsl:when test="$attrSet = '__tableframe__right'">
  105. <xsl:call-template name="new-attr-set-reflection">
  106. <xsl:with-param name="temp-element">
  107. <xsl:element name="placeholder" use-attribute-sets="__tableframe__right"/>
  108. </xsl:with-param>
  109. </xsl:call-template>
  110. </xsl:when>
  111. <xsl:when test="$attrSet = '__tableframe__top'">
  112. <xsl:call-template name="new-attr-set-reflection">
  113. <xsl:with-param name="temp-element">
  114. <xsl:element name="placeholder" use-attribute-sets="__tableframe__top"/>
  115. </xsl:with-param>
  116. </xsl:call-template>
  117. </xsl:when>
  118. <xsl:when test="$attrSet = 'lq'">
  119. <xsl:call-template name="new-attr-set-reflection">
  120. <xsl:with-param name="temp-element">
  121. <xsl:element name="placeholder" use-attribute-sets="lq"/>
  122. </xsl:with-param>
  123. </xsl:call-template>
  124. </xsl:when>
  125. <xsl:when test="$attrSet = 'lq_simple'">
  126. <xsl:call-template name="new-attr-set-reflection">
  127. <xsl:with-param name="temp-element">
  128. <xsl:element name="placeholder" use-attribute-sets="lq_simple"/>
  129. </xsl:with-param>
  130. </xsl:call-template>
  131. </xsl:when>
  132. <xsl:when test="$attrSet = 'table__tableframe__all'">
  133. <xsl:call-template name="new-attr-set-reflection">
  134. <xsl:with-param name="temp-element">
  135. <xsl:element name="placeholder" use-attribute-sets="table__tableframe__all"/>
  136. </xsl:with-param>
  137. </xsl:call-template>
  138. </xsl:when>
  139. <xsl:when test="$attrSet = 'table__tableframe__bottom'">
  140. <xsl:call-template name="new-attr-set-reflection">
  141. <xsl:with-param name="temp-element">
  142. <xsl:element name="placeholder" use-attribute-sets="table__tableframe__bottom"/>
  143. </xsl:with-param>
  144. </xsl:call-template>
  145. </xsl:when>
  146. <xsl:when test="$attrSet = 'table__tableframe__sides'">
  147. <xsl:call-template name="new-attr-set-reflection">
  148. <xsl:with-param name="temp-element">
  149. <xsl:element name="placeholder" use-attribute-sets="table__tableframe__sides"/>
  150. </xsl:with-param>
  151. </xsl:call-template>
  152. </xsl:when>
  153. <xsl:when test="$attrSet = 'table__tableframe__top'">
  154. <xsl:call-template name="new-attr-set-reflection">
  155. <xsl:with-param name="temp-element">
  156. <xsl:element name="placeholder" use-attribute-sets="table__tableframe__top"/>
  157. </xsl:with-param>
  158. </xsl:call-template>
  159. </xsl:when>
  160. <xsl:when test="$attrSet = 'table__tableframe__topbot'">
  161. <xsl:call-template name="new-attr-set-reflection">
  162. <xsl:with-param name="temp-element">
  163. <xsl:element name="placeholder" use-attribute-sets="table__tableframe__topbot"/>
  164. </xsl:with-param>
  165. </xsl:call-template>
  166. </xsl:when>
  167. <xsl:when test="$attrSet = 'thead__tableframe__bottom'">
  168. <xsl:call-template name="new-attr-set-reflection">
  169. <xsl:with-param name="temp-element">
  170. <xsl:element name="placeholder" use-attribute-sets="thead__tableframe__bottom"/>
  171. </xsl:with-param>
  172. </xsl:call-template>
  173. </xsl:when>
  174. <xsl:when test="$attrSet = '__align__left'">
  175. <xsl:call-template name="new-attr-set-reflection">
  176. <xsl:with-param name="temp-element">
  177. <xsl:element name="placeholder" use-attribute-sets="__align__left"/>
  178. </xsl:with-param>
  179. </xsl:call-template>
  180. </xsl:when>
  181. <xsl:when test="$attrSet = '__align__right'">
  182. <xsl:call-template name="new-attr-set-reflection">
  183. <xsl:with-param name="temp-element">
  184. <xsl:element name="placeholder" use-attribute-sets="__align__right"/>
  185. </xsl:with-param>
  186. </xsl:call-template>
  187. </xsl:when>
  188. <xsl:when test="$attrSet = '__align__center'">
  189. <xsl:call-template name="new-attr-set-reflection">
  190. <xsl:with-param name="temp-element">
  191. <xsl:element name="placeholder" use-attribute-sets="__align__center"/>
  192. </xsl:with-param>
  193. </xsl:call-template>
  194. </xsl:when>
  195. <xsl:when test="$attrSet = '__align__justify'">
  196. <xsl:call-template name="new-attr-set-reflection">
  197. <xsl:with-param name="temp-element">
  198. <xsl:element name="placeholder" use-attribute-sets="__align__justify"/>
  199. </xsl:with-param>
  200. </xsl:call-template>
  201. </xsl:when>
  202. <xsl:when test="$attrSet = 'thead.row'">
  203. <xsl:call-template name="new-attr-set-reflection">
  204. <xsl:with-param name="temp-element">
  205. <xsl:element name="placeholder" use-attribute-sets="thead.row"/>
  206. </xsl:with-param>
  207. </xsl:call-template>
  208. </xsl:when>
  209. <xsl:when test="$attrSet = 'thead.row.entry'">
  210. <xsl:call-template name="new-attr-set-reflection">
  211. <xsl:with-param name="temp-element">
  212. <xsl:element name="placeholder" use-attribute-sets="thead.row.entry"/>
  213. </xsl:with-param>
  214. </xsl:call-template>
  215. </xsl:when>
  216. <xsl:when test="$attrSet = 'thead.row.entry__content'">
  217. <xsl:call-template name="new-attr-set-reflection">
  218. <xsl:with-param name="temp-element">
  219. <xsl:element name="placeholder" use-attribute-sets="thead.row.entry__content"/>
  220. </xsl:with-param>
  221. </xsl:call-template>
  222. </xsl:when>
  223. <xsl:when test="$attrSet = 'tfoot.row'">
  224. <xsl:call-template name="new-attr-set-reflection">
  225. <xsl:with-param name="temp-element">
  226. <xsl:element name="placeholder" use-attribute-sets="tfoot.row"/>
  227. </xsl:with-param>
  228. </xsl:call-template>
  229. </xsl:when>
  230. <xsl:when test="$attrSet = 'tfoot.row.entry'">
  231. <xsl:call-template name="new-attr-set-reflection">
  232. <xsl:with-param name="temp-element">
  233. <xsl:element name="placeholder" use-attribute-sets="tfoot.row.entry"/>
  234. </xsl:with-param>
  235. </xsl:call-template>
  236. </xsl:when>
  237. <xsl:when test="$attrSet = 'tfoot.row.entry__content'">
  238. <xsl:call-template name="new-attr-set-reflection">
  239. <xsl:with-param name="temp-element">
  240. <xsl:element name="placeholder" use-attribute-sets="tfoot.row.entry__content"/>
  241. </xsl:with-param>
  242. </xsl:call-template>
  243. </xsl:when>
  244. <xsl:when test="$attrSet = 'tbody.row'">
  245. <xsl:call-template name="new-attr-set-reflection">
  246. <xsl:with-param name="temp-element">
  247. <xsl:element name="placeholder" use-attribute-sets="tbody.row"/>
  248. </xsl:with-param>
  249. </xsl:call-template>
  250. </xsl:when>
  251. <xsl:when test="$attrSet = 'tbody.row.entry'">
  252. <xsl:call-template name="new-attr-set-reflection">
  253. <xsl:with-param name="temp-element">
  254. <xsl:element name="placeholder" use-attribute-sets="tbody.row.entry"/>
  255. </xsl:with-param>
  256. </xsl:call-template>
  257. </xsl:when>
  258. <xsl:when test="$attrSet = 'tbody.row.entry__content'">
  259. <xsl:call-template name="new-attr-set-reflection">
  260. <xsl:with-param name="temp-element">
  261. <xsl:element name="placeholder" use-attribute-sets="tbody.row.entry__content"/>
  262. </xsl:with-param>
  263. </xsl:call-template>
  264. </xsl:when>
  265. <xsl:when test="$attrSet = 'topic.title__content'">
  266. <xsl:call-template name="new-attr-set-reflection">
  267. <xsl:with-param name="temp-element">
  268. <xsl:element name="placeholder" use-attribute-sets="topic.title__content"/>
  269. </xsl:with-param>
  270. </xsl:call-template>
  271. </xsl:when>
  272. <xsl:when test="$attrSet = 'topic.topic.title__content'">
  273. <xsl:call-template name="new-attr-set-reflection">
  274. <xsl:with-param name="temp-element">
  275. <xsl:element name="placeholder" use-attribute-sets="topic.topic.title__content"/>
  276. </xsl:with-param>
  277. </xsl:call-template>
  278. </xsl:when>
  279. <xsl:when test="$attrSet = 'topic.topic.topic.title__content'">
  280. <xsl:call-template name="new-attr-set-reflection">
  281. <xsl:with-param name="temp-element">
  282. <xsl:element name="placeholder" use-attribute-sets="topic.topic.topic.title__content"/>
  283. </xsl:with-param>
  284. </xsl:call-template>
  285. </xsl:when>
  286. <xsl:when test="$attrSet = 'topic.topic.topic.topic.title__content'">
  287. <xsl:call-template name="new-attr-set-reflection">
  288. <xsl:with-param name="temp-element">
  289. <xsl:element name="placeholder" use-attribute-sets="topic.topic.topic.topic.title__content"/>
  290. </xsl:with-param>
  291. </xsl:call-template>
  292. </xsl:when>
  293. <xsl:when test="$attrSet = 'topic.topic.topic.topic.topic.title__content'">
  294. <xsl:call-template name="new-attr-set-reflection">
  295. <xsl:with-param name="temp-element">
  296. <xsl:element name="placeholder" use-attribute-sets="topic.topic.topic.topic.topic.title__content"/>
  297. </xsl:with-param>
  298. </xsl:call-template>
  299. </xsl:when>
  300. <xsl:when test="$attrSet = 'topic.topic.topic.topic.topic.topic.title__content'">
  301. <xsl:call-template name="new-attr-set-reflection">
  302. <xsl:with-param name="temp-element">
  303. <xsl:element name="placeholder" use-attribute-sets="topic.topic.topic.topic.topic.topic.title__content"/>
  304. </xsl:with-param>
  305. </xsl:call-template>
  306. </xsl:when>
  307. <xsl:when test="doc-available('cfg:fo/attrs/custom.xsl') and document('cfg:fo/attrs/custom.xsl')//xsl:attribute-set[@name = $attrSet]">
  308. <xsl:apply-templates select="document('cfg:fo/attrs/custom.xsl')//xsl:attribute-set[@name = $attrSet]"/>
  309. </xsl:when>
  310. <xsl:otherwise>
  311. <xsl:apply-templates select="document($path)//xsl:attribute-set[@name = $attrSet]"/>
  312. </xsl:otherwise>
  313. </xsl:choose>
  314. </xsl:template>
  315. <xsl:template match="xsl:attribute-set">
  316. <xsl:if test="@use-attribute-sets">
  317. <xsl:call-template name="processNestedAttrSets">
  318. <xsl:with-param name="setNames" select="normalize-space(@use-attribute-sets)"/>
  319. </xsl:call-template>
  320. </xsl:if>
  321. <xsl:for-each select="xsl:attribute">
  322. <xsl:attribute name="{@name}">
  323. <xsl:value-of select="."/>
  324. </xsl:attribute>
  325. <xsl:for-each select="xsl:*">
  326. <xsl:call-template name="output-message">
  327. <xsl:with-param name="id" select="'PDFX009E'"/>
  328. <xsl:with-param name="msgparams">%1=<xsl:value-of select="name()"/></xsl:with-param>
  329. </xsl:call-template>
  330. </xsl:for-each>
  331. </xsl:for-each>
  332. </xsl:template>
  333. <xsl:template name="processNestedAttrSets">
  334. <xsl:param name="setNames"/>
  335. <xsl:choose>
  336. <xsl:when test="contains($setNames, ' ')">
  337. <xsl:apply-templates select="//xsl:attribute-set[@name = substring-before($setNames, ' ')]"/>
  338. <xsl:call-template name="processNestedAttrSets">
  339. <xsl:with-param name="setNames" select="substring-after($setNames, ' ')"/>
  340. </xsl:call-template>
  341. </xsl:when>
  342. <xsl:otherwise>
  343. <xsl:apply-templates select="//xsl:attribute-set[@name = $setNames]"/>
  344. </xsl:otherwise>
  345. </xsl:choose>
  346. </xsl:template>
  347. </xsl:stylesheet>