lib.xsl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <?xml version="1.0"?>
  2. <!-- ********************************************************************
  3. $Id: lib.xweb 9040 2011-08-19 21:51:47Z bobstayton $
  4. ********************************************************************
  5. This file is part of the XSL DocBook Stylesheet distribution.
  6. See ../README or http://docbook.sf.net/release/xsl/current/ for
  7. copyright and other information.
  8. This module implements DTD-independent functions
  9. ******************************************************************** -->
  10. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  11. <xsl:template name="dot.count">
  12. <!-- Returns the number of "." characters in a string -->
  13. <xsl:param name="string"/>
  14. <xsl:param name="count" select="0"/>
  15. <xsl:choose>
  16. <xsl:when test="contains($string, '.')">
  17. <xsl:call-template name="dot.count">
  18. <xsl:with-param name="string" select="substring-after($string, '.')"/>
  19. <xsl:with-param name="count" select="$count+1"/>
  20. </xsl:call-template>
  21. </xsl:when>
  22. <xsl:otherwise>
  23. <xsl:value-of select="$count"/>
  24. </xsl:otherwise>
  25. </xsl:choose>
  26. </xsl:template>
  27. <xsl:template name="copy-string">
  28. <!-- returns 'count' copies of 'string' -->
  29. <xsl:param name="string"/>
  30. <xsl:param name="count" select="0"/>
  31. <xsl:param name="result"/>
  32. <xsl:choose>
  33. <xsl:when test="$count&gt;0">
  34. <xsl:call-template name="copy-string">
  35. <xsl:with-param name="string" select="$string"/>
  36. <xsl:with-param name="count" select="$count - 1"/>
  37. <xsl:with-param name="result">
  38. <xsl:value-of select="$result"/>
  39. <xsl:value-of select="$string"/>
  40. </xsl:with-param>
  41. </xsl:call-template>
  42. </xsl:when>
  43. <xsl:otherwise>
  44. <xsl:value-of select="$result"/>
  45. </xsl:otherwise>
  46. </xsl:choose>
  47. </xsl:template>
  48. <xsl:template name="string.subst">
  49. <xsl:param name="string"/>
  50. <xsl:param name="target"/>
  51. <xsl:param name="replacement"/>
  52. <xsl:choose>
  53. <xsl:when test="contains($string, $target)">
  54. <xsl:variable name="rest">
  55. <xsl:call-template name="string.subst">
  56. <xsl:with-param name="string" select="substring-after($string, $target)"/>
  57. <xsl:with-param name="target" select="$target"/>
  58. <xsl:with-param name="replacement" select="$replacement"/>
  59. </xsl:call-template>
  60. </xsl:variable>
  61. <xsl:value-of select="concat(substring-before($string, $target), $replacement, $rest)"/>
  62. </xsl:when>
  63. <xsl:otherwise>
  64. <xsl:value-of select="$string"/>
  65. </xsl:otherwise>
  66. </xsl:choose>
  67. </xsl:template>
  68. <xsl:template name="xpointer.idref">
  69. <xsl:param name="xpointer">http://...</xsl:param>
  70. <xsl:choose>
  71. <xsl:when test="starts-with($xpointer, '#xpointer(id(')">
  72. <xsl:variable name="rest" select="substring-after($xpointer, '#xpointer(id(')"/>
  73. <xsl:variable name="quote" select="substring($rest, 1, 1)"/>
  74. <xsl:value-of select="substring-before(substring-after($xpointer, $quote), $quote)"/>
  75. </xsl:when>
  76. <xsl:when test="starts-with($xpointer, '#')">
  77. <xsl:value-of select="substring-after($xpointer, '#')"/>
  78. </xsl:when>
  79. <!-- otherwise it's a pointer to some other document -->
  80. </xsl:choose>
  81. </xsl:template>
  82. <xsl:template name="length-magnitude">
  83. <xsl:param name="length" select="'0pt'"/>
  84. <xsl:choose>
  85. <xsl:when test="string-length($length) = 0"/>
  86. <xsl:when test="substring($length,1,1) = '0' or substring($length,1,1) = '1' or substring($length,1,1) = '2' or substring($length,1,1) = '3' or substring($length,1,1) = '4' or substring($length,1,1) = '5' or substring($length,1,1) = '6' or substring($length,1,1) = '7' or substring($length,1,1) = '8' or substring($length,1,1) = '9' or substring($length,1,1) = '.'">
  87. <xsl:value-of select="substring($length,1,1)"/>
  88. <xsl:call-template name="length-magnitude">
  89. <xsl:with-param name="length" select="substring($length,2)"/>
  90. </xsl:call-template>
  91. </xsl:when>
  92. </xsl:choose>
  93. </xsl:template>
  94. <xsl:template name="length-units">
  95. <xsl:param name="length" select="'0pt'"/>
  96. <xsl:param name="default.units" select="'px'"/>
  97. <xsl:variable name="magnitude">
  98. <xsl:call-template name="length-magnitude">
  99. <xsl:with-param name="length" select="$length"/>
  100. </xsl:call-template>
  101. </xsl:variable>
  102. <xsl:variable name="units">
  103. <xsl:value-of select="substring($length, string-length($magnitude)+1)"/>
  104. </xsl:variable>
  105. <xsl:choose>
  106. <xsl:when test="$units = ''">
  107. <xsl:value-of select="$default.units"/>
  108. </xsl:when>
  109. <xsl:otherwise>
  110. <xsl:value-of select="$units"/>
  111. </xsl:otherwise>
  112. </xsl:choose>
  113. </xsl:template>
  114. <xsl:template name="length-spec">
  115. <xsl:param name="length" select="'0pt'"/>
  116. <xsl:param name="default.units" select="'px'"/>
  117. <xsl:variable name="magnitude">
  118. <xsl:call-template name="length-magnitude">
  119. <xsl:with-param name="length" select="$length"/>
  120. </xsl:call-template>
  121. </xsl:variable>
  122. <xsl:variable name="units">
  123. <xsl:value-of select="substring($length, string-length($magnitude)+1)"/>
  124. </xsl:variable>
  125. <xsl:value-of select="$magnitude"/>
  126. <xsl:choose>
  127. <xsl:when test="$units='cm' or $units='mm' or $units='in' or $units='pt' or $units='pc' or $units='px' or $units='em'">
  128. <xsl:value-of select="$units"/>
  129. </xsl:when>
  130. <xsl:when test="$units = ''">
  131. <xsl:value-of select="$default.units"/>
  132. </xsl:when>
  133. <xsl:otherwise>
  134. <xsl:message>
  135. <xsl:text>Unrecognized unit of measure: </xsl:text>
  136. <xsl:value-of select="$units"/>
  137. <xsl:text>.</xsl:text>
  138. </xsl:message>
  139. </xsl:otherwise>
  140. </xsl:choose>
  141. </xsl:template>
  142. <xsl:template name="length-in-points">
  143. <xsl:param name="length" select="'0pt'"/>
  144. <xsl:param name="em.size" select="10"/>
  145. <xsl:param name="pixels.per.inch" select="90"/>
  146. <xsl:variable name="magnitude">
  147. <xsl:call-template name="length-magnitude">
  148. <xsl:with-param name="length" select="$length"/>
  149. </xsl:call-template>
  150. </xsl:variable>
  151. <xsl:variable name="units">
  152. <xsl:value-of select="substring($length, string-length($magnitude)+1)"/>
  153. </xsl:variable>
  154. <xsl:choose>
  155. <xsl:when test="$units = 'pt'">
  156. <xsl:value-of select="$magnitude"/>
  157. </xsl:when>
  158. <xsl:when test="$units = 'cm'">
  159. <xsl:value-of select="$magnitude div 2.54 * 72.0"/>
  160. </xsl:when>
  161. <xsl:when test="$units = 'mm'">
  162. <xsl:value-of select="$magnitude div 25.4 * 72.0"/>
  163. </xsl:when>
  164. <xsl:when test="$units = 'in'">
  165. <xsl:value-of select="$magnitude * 72.0"/>
  166. </xsl:when>
  167. <xsl:when test="$units = 'pc'">
  168. <xsl:value-of select="$magnitude * 12.0"/>
  169. </xsl:when>
  170. <xsl:when test="$units = 'px'">
  171. <xsl:value-of select="$magnitude div $pixels.per.inch * 72.0"/>
  172. </xsl:when>
  173. <xsl:when test="$units = 'em'">
  174. <xsl:value-of select="$magnitude * $em.size"/>
  175. </xsl:when>
  176. <xsl:otherwise>
  177. <xsl:message>
  178. <xsl:text>Unrecognized unit of measure: </xsl:text>
  179. <xsl:value-of select="$units"/>
  180. <xsl:text>.</xsl:text>
  181. </xsl:message>
  182. </xsl:otherwise>
  183. </xsl:choose>
  184. </xsl:template>
  185. <xsl:template name="pi-attribute">
  186. <xsl:param name="pis" select="processing-instruction('BOGUS_PI')"/>
  187. <xsl:param name="attribute">filename</xsl:param>
  188. <xsl:param name="count">1</xsl:param>
  189. <xsl:choose>
  190. <xsl:when test="$count&gt;count($pis)">
  191. <!-- not found -->
  192. </xsl:when>
  193. <xsl:otherwise>
  194. <xsl:variable name="pi">
  195. <xsl:value-of select="$pis[$count]"/>
  196. </xsl:variable>
  197. <xsl:variable name="pivalue">
  198. <xsl:value-of select="concat(' ', normalize-space($pi))"/>
  199. </xsl:variable>
  200. <xsl:choose>
  201. <xsl:when test="contains($pivalue,concat(' ', $attribute, '='))">
  202. <xsl:variable name="rest" select="substring-after($pivalue,concat(' ', $attribute,'='))"/>
  203. <xsl:variable name="quote" select="substring($rest,1,1)"/>
  204. <xsl:value-of select="substring-before(substring($rest,2),$quote)"/>
  205. </xsl:when>
  206. <xsl:otherwise>
  207. <xsl:call-template name="pi-attribute">
  208. <xsl:with-param name="pis" select="$pis"/>
  209. <xsl:with-param name="attribute" select="$attribute"/>
  210. <xsl:with-param name="count" select="$count + 1"/>
  211. </xsl:call-template>
  212. </xsl:otherwise>
  213. </xsl:choose>
  214. </xsl:otherwise>
  215. </xsl:choose>
  216. </xsl:template>
  217. <xsl:template name="lookup.key">
  218. <xsl:param name="key" select="''"/>
  219. <xsl:param name="table" select="''"/>
  220. <xsl:if test="contains($table, ' ')">
  221. <xsl:choose>
  222. <xsl:when test="substring-before($table, ' ') = $key">
  223. <xsl:variable name="rest" select="substring-after($table, ' ')"/>
  224. <xsl:choose>
  225. <xsl:when test="contains($rest, ' ')">
  226. <xsl:value-of select="substring-before($rest, ' ')"/>
  227. </xsl:when>
  228. <xsl:otherwise>
  229. <xsl:value-of select="$rest"/>
  230. </xsl:otherwise>
  231. </xsl:choose>
  232. </xsl:when>
  233. <xsl:otherwise>
  234. <xsl:call-template name="lookup.key">
  235. <xsl:with-param name="key" select="$key"/>
  236. <xsl:with-param name="table" select="substring-after(substring-after($table,' '), ' ')"/>
  237. </xsl:call-template>
  238. </xsl:otherwise>
  239. </xsl:choose>
  240. </xsl:if>
  241. </xsl:template>
  242. <xsl:template name="xpath.location">
  243. <xsl:param name="node" select="."/>
  244. <xsl:param name="path" select="''"/>
  245. <xsl:variable name="next.path">
  246. <xsl:value-of select="local-name($node)"/>
  247. <xsl:if test="$path != ''">/</xsl:if>
  248. <xsl:value-of select="$path"/>
  249. </xsl:variable>
  250. <xsl:choose>
  251. <xsl:when test="$node/parent::*">
  252. <xsl:call-template name="xpath.location">
  253. <xsl:with-param name="node" select="$node/parent::*"/>
  254. <xsl:with-param name="path" select="$next.path"/>
  255. </xsl:call-template>
  256. </xsl:when>
  257. <xsl:otherwise>
  258. <xsl:text>/</xsl:text>
  259. <xsl:value-of select="$next.path"/>
  260. </xsl:otherwise>
  261. </xsl:choose>
  262. </xsl:template>
  263. <xsl:template name="comment-escape-string">
  264. <xsl:param name="string" select="''"/>
  265. <xsl:if test="starts-with($string, '-')">
  266. <xsl:text> </xsl:text>
  267. </xsl:if>
  268. <xsl:call-template name="comment-escape-string.recursive">
  269. <xsl:with-param name="string" select="$string"/>
  270. </xsl:call-template>
  271. <xsl:if test="substring($string, string-length($string), 1) = '-'">
  272. <xsl:text> </xsl:text>
  273. </xsl:if>
  274. </xsl:template>
  275. <xsl:template name="comment-escape-string.recursive">
  276. <xsl:param name="string" select="''"/>
  277. <xsl:choose>
  278. <xsl:when test="contains($string, '--')">
  279. <xsl:value-of select="substring-before($string, '--')"/>
  280. <xsl:value-of select="'- -'"/>
  281. <xsl:call-template name="comment-escape-string.recursive">
  282. <xsl:with-param name="string" select="substring-after($string, '--')"/>
  283. </xsl:call-template>
  284. </xsl:when>
  285. <xsl:otherwise>
  286. <xsl:value-of select="$string"/>
  287. </xsl:otherwise>
  288. </xsl:choose>
  289. </xsl:template>
  290. <xsl:template name="str.tokenize.keep.delimiters">
  291. <xsl:param name="string" select="''"/>
  292. <xsl:param name="delimiters" select="' '"/>
  293. <xsl:choose>
  294. <xsl:when test="not($string)"/>
  295. <xsl:when test="not($delimiters)">
  296. <xsl:call-template name="str.tokenize.keep.delimiters-characters">
  297. <xsl:with-param name="string" select="$string"/>
  298. </xsl:call-template>
  299. </xsl:when>
  300. <xsl:otherwise>
  301. <xsl:call-template name="str.tokenize.keep.delimiters-delimiters">
  302. <xsl:with-param name="string" select="$string"/>
  303. <xsl:with-param name="delimiters" select="$delimiters"/>
  304. </xsl:call-template>
  305. </xsl:otherwise>
  306. </xsl:choose>
  307. </xsl:template>
  308. <xsl:template name="str.tokenize.keep.delimiters-characters">
  309. <xsl:param name="string"/>
  310. <xsl:if test="$string">
  311. <ssb:token xmlns:ssb="http://sideshowbarker.net/ns"><xsl:value-of select="substring($string, 1, 1)"/></ssb:token>
  312. <xsl:call-template name="str.tokenize.keep.delimiters-characters">
  313. <xsl:with-param name="string" select="substring($string, 2)"/>
  314. </xsl:call-template>
  315. </xsl:if>
  316. </xsl:template>
  317. <xsl:template name="str.tokenize.keep.delimiters-delimiters">
  318. <xsl:param name="string"/>
  319. <xsl:param name="delimiters"/>
  320. <xsl:variable name="delimiter" select="substring($delimiters, 1, 1)"/>
  321. <xsl:choose>
  322. <xsl:when test="not($delimiter)">
  323. <ssb:token xmlns:ssb="http://sideshowbarker.net/ns"><xsl:value-of select="$string"/></ssb:token>
  324. </xsl:when>
  325. <xsl:when test="contains($string, $delimiter)">
  326. <xsl:if test="not(starts-with($string, $delimiter))">
  327. <xsl:call-template name="str.tokenize.keep.delimiters-delimiters">
  328. <xsl:with-param name="string" select="substring-before($string, $delimiter)"/>
  329. <xsl:with-param name="delimiters" select="substring($delimiters, 2)"/>
  330. </xsl:call-template>
  331. </xsl:if>
  332. <!-- output each delimiter -->
  333. <xsl:value-of select="$delimiter"/>
  334. <xsl:call-template name="str.tokenize.keep.delimiters-delimiters">
  335. <xsl:with-param name="string" select="substring-after($string, $delimiter)"/>
  336. <xsl:with-param name="delimiters" select="$delimiters"/>
  337. </xsl:call-template>
  338. </xsl:when>
  339. <xsl:otherwise>
  340. <xsl:call-template name="str.tokenize.keep.delimiters-delimiters">
  341. <xsl:with-param name="string" select="$string"/>
  342. <xsl:with-param name="delimiters" select="substring($delimiters, 2)"/>
  343. </xsl:call-template>
  344. </xsl:otherwise>
  345. </xsl:choose>
  346. </xsl:template>
  347. <xsl:template name="apply-string-subst-map">
  348. <xsl:param name="content"/>
  349. <xsl:param name="map.contents"/>
  350. <xsl:variable name="replaced_text">
  351. <xsl:call-template name="string.subst">
  352. <xsl:with-param name="string" select="$content"/>
  353. <xsl:with-param name="target" select="$map.contents[1]/@oldstring"/>
  354. <xsl:with-param name="replacement" select="$map.contents[1]/@newstring"/>
  355. </xsl:call-template>
  356. </xsl:variable>
  357. <xsl:choose>
  358. <xsl:when test="$map.contents[2]">
  359. <xsl:call-template name="apply-string-subst-map">
  360. <xsl:with-param name="content" select="$replaced_text"/>
  361. <xsl:with-param name="map.contents" select="$map.contents[position() &gt; 1]"/>
  362. </xsl:call-template>
  363. </xsl:when>
  364. <xsl:otherwise>
  365. <xsl:value-of select="$replaced_text"/>
  366. </xsl:otherwise>
  367. </xsl:choose>
  368. </xsl:template>
  369. <xsl:template name="count.uri.path.depth">
  370. <xsl:param name="filename" select="''"/>
  371. <xsl:param name="count" select="0"/>
  372. <xsl:choose>
  373. <xsl:when test="contains($filename, '/')">
  374. <xsl:call-template name="count.uri.path.depth">
  375. <xsl:with-param name="filename" select="substring-after($filename, '/')"/>
  376. <xsl:with-param name="count" select="$count + 1"/>
  377. </xsl:call-template>
  378. </xsl:when>
  379. <xsl:otherwise>
  380. <xsl:value-of select="$count"/>
  381. </xsl:otherwise>
  382. </xsl:choose>
  383. </xsl:template>
  384. <xsl:template name="trim.common.uri.paths">
  385. <xsl:param name="uriA" select="''"/>
  386. <xsl:param name="uriB" select="''"/>
  387. <xsl:param name="return" select="'A'"/>
  388. <!-- Resolve any ../ in the path -->
  389. <xsl:variable name="trimmed.uriA">
  390. <xsl:call-template name="resolve.path">
  391. <xsl:with-param name="filename" select="$uriA"/>
  392. </xsl:call-template>
  393. </xsl:variable>
  394. <xsl:variable name="trimmed.uriB">
  395. <xsl:call-template name="resolve.path">
  396. <xsl:with-param name="filename" select="$uriB"/>
  397. </xsl:call-template>
  398. </xsl:variable>
  399. <xsl:choose>
  400. <xsl:when test="contains($trimmed.uriA, '/') and contains($trimmed.uriB, '/') and substring-before($trimmed.uriA, '/') = substring-before($trimmed.uriB, '/')">
  401. <xsl:call-template name="trim.common.uri.paths">
  402. <xsl:with-param name="uriA" select="substring-after($trimmed.uriA, '/')"/>
  403. <xsl:with-param name="uriB" select="substring-after($trimmed.uriB, '/')"/>
  404. <xsl:with-param name="return" select="$return"/>
  405. </xsl:call-template>
  406. </xsl:when>
  407. <xsl:otherwise>
  408. <xsl:choose>
  409. <xsl:when test="$return = 'A'">
  410. <xsl:value-of select="$trimmed.uriA"/>
  411. </xsl:when>
  412. <xsl:otherwise>
  413. <xsl:value-of select="$trimmed.uriB"/>
  414. </xsl:otherwise>
  415. </xsl:choose>
  416. </xsl:otherwise>
  417. </xsl:choose>
  418. </xsl:template>
  419. <xsl:template name="resolve.path">
  420. <xsl:param name="filename" select="''"/>
  421. <xsl:choose>
  422. <!-- Leading .. are not eliminated -->
  423. <xsl:when test="starts-with($filename, '../')">
  424. <xsl:value-of select="'../'"/>
  425. <xsl:call-template name="resolve.path">
  426. <xsl:with-param name="filename" select="substring-after($filename, '../')"/>
  427. </xsl:call-template>
  428. </xsl:when>
  429. <xsl:when test="contains($filename, '/../')">
  430. <xsl:call-template name="resolve.path">
  431. <xsl:with-param name="filename">
  432. <xsl:call-template name="dirname">
  433. <xsl:with-param name="filename" select="substring-before($filename, '/../')"/>
  434. </xsl:call-template>
  435. <xsl:value-of select="substring-after($filename, '/../')"/>
  436. </xsl:with-param>
  437. </xsl:call-template>
  438. </xsl:when>
  439. <xsl:otherwise>
  440. <xsl:value-of select="$filename"/>
  441. </xsl:otherwise>
  442. </xsl:choose>
  443. </xsl:template>
  444. <xsl:template name="dirname">
  445. <xsl:param name="filename" select="''"/>
  446. <xsl:if test="contains($filename, '/')">
  447. <xsl:value-of select="substring-before($filename, '/')"/>
  448. <xsl:text>/</xsl:text>
  449. <xsl:call-template name="dirname">
  450. <xsl:with-param name="filename" select="substring-after($filename, '/')"/>
  451. </xsl:call-template>
  452. </xsl:if>
  453. </xsl:template>
  454. <xsl:template name="trim.text">
  455. <xsl:param name="contents" select="."/>
  456. <xsl:variable name="contents-left-trimmed">
  457. <xsl:call-template name="trim-left">
  458. <xsl:with-param name="contents" select="$contents"/>
  459. </xsl:call-template>
  460. </xsl:variable>
  461. <xsl:variable name="contents-trimmed">
  462. <xsl:call-template name="trim-right">
  463. <xsl:with-param name="contents" select="$contents-left-trimmed"/>
  464. </xsl:call-template>
  465. </xsl:variable>
  466. <xsl:value-of select="$contents-trimmed"/>
  467. </xsl:template>
  468. <xsl:template name="trim-left">
  469. <xsl:param name="contents"/>
  470. <xsl:choose>
  471. <xsl:when test="starts-with($contents,'&#10;') or starts-with($contents,'&#13;') or starts-with($contents,' ') or starts-with($contents,'&#9;')">
  472. <xsl:call-template name="trim-left">
  473. <xsl:with-param name="contents" select="substring($contents, 2)"/>
  474. </xsl:call-template>
  475. </xsl:when>
  476. <xsl:otherwise>
  477. <xsl:value-of select="$contents"/>
  478. </xsl:otherwise>
  479. </xsl:choose>
  480. </xsl:template>
  481. <xsl:template name="trim-right">
  482. <xsl:param name="contents"/>
  483. <xsl:variable name="last-char">
  484. <xsl:value-of select="substring($contents, string-length($contents), 1)"/>
  485. </xsl:variable>
  486. <xsl:choose>
  487. <xsl:when test="($last-char = '&#10;') or ($last-char = '&#13;') or ($last-char = ' ') or ($last-char = '&#9;')">
  488. <xsl:call-template name="trim-right">
  489. <xsl:with-param name="contents" select="substring($contents, 1, string-length($contents) - 1)"/>
  490. </xsl:call-template>
  491. </xsl:when>
  492. <xsl:otherwise>
  493. <xsl:value-of select="$contents"/>
  494. </xsl:otherwise>
  495. </xsl:choose>
  496. </xsl:template>
  497. </xsl:stylesheet>