dbk2wp.xsl 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  1. <xsl:stylesheet version="1.0"
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:doc='http://docbook.org/ns/docbook'
  4. exclude-result-prefixes='doc'>
  5. <!-- ********************************************************************
  6. $Id: dbk2wp.xsl 9396 2012-06-02 21:56:19Z bobstayton $
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- DO NOT USE THIS STYLESHEET!
  13. This stylesheet is imported by the other dbk2* stylesheets.
  14. Use one of those instead.
  15. -->
  16. <xsl:include href='../VERSION.xsl'/>
  17. <!-- doc:docprop.author mode is for creating document metadata -->
  18. <xsl:template match='author|doc:author|editor|doc:editor' mode='doc:docprop.author'>
  19. <xsl:apply-templates select='firstname|doc:firstname |
  20. personname/firstname|doc:personname/doc:firstname'
  21. mode='doc:docprop.author'/>
  22. <xsl:text> </xsl:text>
  23. <xsl:apply-templates select='surname|doc:surname |
  24. personname/surname|doc:personname/doc:surname'
  25. mode='doc:docprop.author'/>
  26. </xsl:template>
  27. <xsl:template match='firstname|doc:firstname |
  28. surname|doc:surname'
  29. mode='doc:docprop.author'>
  30. <xsl:apply-templates select='.' mode='doc:body'/>
  31. </xsl:template>
  32. <!-- doc:toplevel mode is for processing whole documents -->
  33. <xsl:template match='*' mode='doc:toplevel'>
  34. <xsl:call-template name='doc:make-body'/>
  35. </xsl:template>
  36. <!-- doc:body mode is for processing components of a document -->
  37. <xsl:template match='book|article|chapter|section|sect1|sect2|sect3|sect4|sect5|simplesect |
  38. doc:book|doc:article|doc:chapter|doc:section|doc:sect1|doc:sect2|doc:sect3|doc:sect4|doc:sect5|doc:simplesect'
  39. mode='doc:body'>
  40. <xsl:call-template name='doc:make-subsection'/>
  41. </xsl:template>
  42. <xsl:template match='articleinfo |
  43. chapterinfo |
  44. bookinfo |
  45. doc:info |
  46. doc:articleinfo |
  47. doc:chapterinfo |
  48. doc:bookinfo'
  49. mode='doc:body'>
  50. <xsl:apply-templates select='title|subtitle|titleabbrev |
  51. doc:title|doc:subtitle|doc:titleabbrev'
  52. mode='doc:body'/>
  53. <xsl:apply-templates select='author|releaseinfo|abstract |
  54. doc:author|doc:releaseinfo|doc:abstract'
  55. mode='doc:body'/>
  56. <!-- current implementation ignores all other metadata -->
  57. <xsl:for-each select='*[not(self::title|self::subtitle|self::titleabbrev|self::author|self::releaseinfo|self::abstract |
  58. self::doc:title|self::doc:subtitle|self::doc:titleabbrev|self::doc:author|self::doc:releaseinfo|self::doc:abstract)]'>
  59. <xsl:call-template name='doc:nomatch'/>
  60. </xsl:for-each>
  61. </xsl:template>
  62. <xsl:template match='title|subtitle|titleabbrev |
  63. doc:title|doc:subtitle|doc:titleabbrev'
  64. mode='doc:body'>
  65. <xsl:call-template name='doc:make-paragraph'>
  66. <xsl:with-param name='style'>
  67. <xsl:choose>
  68. <xsl:when test='(parent::section|parent::doc:section or
  69. parent::sectioninfo/parent::section|parent::doc:sectioninfo/parent::doc:section) and
  70. count(ancestor::section|ancestor::doc:section) > 5'>
  71. <xsl:call-template name='doc:warning'>
  72. <xsl:with-param name='message'>section nested deeper than 5 levels</xsl:with-param>
  73. </xsl:call-template>
  74. <xsl:text>sect5-</xsl:text>
  75. <xsl:value-of select='local-name()'/>
  76. </xsl:when>
  77. <xsl:when test='parent::section|parent::doc:section or
  78. parent::sectioninfo/parent::section|parent::doc:sectioninfo/parent::doc:section'>
  79. <xsl:text>sect</xsl:text>
  80. <xsl:value-of select='count(ancestor::section|ancestor::doc:section)'/>
  81. <xsl:text>-</xsl:text>
  82. <xsl:value-of select='local-name()'/>
  83. </xsl:when>
  84. <xsl:when test='contains(local-name(..), "info")'>
  85. <xsl:value-of select='local-name(../..)'/>
  86. <xsl:text>-</xsl:text>
  87. <xsl:value-of select='local-name()'/>
  88. </xsl:when>
  89. <xsl:otherwise>
  90. <xsl:value-of select='local-name(..)'/>
  91. <xsl:text>-</xsl:text>
  92. <xsl:value-of select='local-name()'/>
  93. </xsl:otherwise>
  94. </xsl:choose>
  95. </xsl:with-param>
  96. <xsl:with-param name='outline.level'
  97. select='count(ancestor::*) - count(parent::*[contains(local-name(), "info")]) - 1'/>
  98. <xsl:with-param name='attributes.node'
  99. select='../parent::*[contains(local-name(current()), "info")] |
  100. parent::*[not(contains(local-name(current()), "info"))]'/>
  101. <xsl:with-param name='content'>
  102. <xsl:apply-templates mode='doc:body'/>
  103. </xsl:with-param>
  104. </xsl:call-template>
  105. </xsl:template>
  106. <doc:template name='metadata' xmlns=''>
  107. <title>Metadata</title>
  108. <para>TODO: Handle all metadata elements, apart from titles.</para>
  109. </doc:template>
  110. <xsl:template match='*[contains(local-name(), "info")]/*[not(self::title|self::subtitle|self::titleabbrev|self::doc:title|self::doc:subtitle|self::doc:titleabbrev)]'
  111. priority='0'
  112. mode='doc:body'/>
  113. <xsl:template match='author|editor|othercredit |
  114. doc:author|doc:editor|doc:othercredit'
  115. mode='doc:body'>
  116. <xsl:call-template name='doc:make-paragraph'>
  117. <xsl:with-param name='style'
  118. select='local-name()'/>
  119. <xsl:with-param name='content'>
  120. <xsl:apply-templates select='personname|surname|firstname|honorific|lineage|othername|contrib |
  121. doc:personname|doc:surname|doc:firstname|doc:honorific|doc:lineage|doc:othername|doc:contrib'
  122. mode='doc:body'/>
  123. </xsl:with-param>
  124. </xsl:call-template>
  125. <xsl:apply-templates select='affiliation|address |
  126. doc:affiliation|doc:address'
  127. mode='doc:body'/>
  128. <xsl:apply-templates select='authorblurb|personblurb |
  129. doc:authorblurb|doc:personblurb'
  130. mode='doc:body'/>
  131. </xsl:template>
  132. <xsl:template match='affiliation|doc:affiliation'
  133. mode='doc:body'>
  134. <xsl:call-template name='doc:make-paragraph'>
  135. <xsl:with-param name='style' select='"affiliation"'/>
  136. <xsl:with-param name='content'>
  137. <xsl:apply-templates mode='doc:body'/>
  138. </xsl:with-param>
  139. </xsl:call-template>
  140. </xsl:template>
  141. <xsl:template match='address[parent::author|parent::editor|parent::othercredit] |
  142. doc:address[parent::doc:author|parent::doc:editor|parent::doc:othercredit]'
  143. mode='doc:body'>
  144. <xsl:call-template name='doc:make-paragraph'>
  145. <xsl:with-param name='style' select='"address"'/>
  146. <xsl:with-param name='content'>
  147. <xsl:apply-templates mode='doc:body'/>
  148. </xsl:with-param>
  149. </xsl:call-template>
  150. </xsl:template>
  151. <!-- do not attempt to handle recursive structures -->
  152. <xsl:template match='address[not(parent::author|parent::editor|parent::othercredit)] |
  153. doc:address[not(parent::doc:author|parent::doc:editor|parent::doc:othercredit)]'
  154. mode='doc:body'>
  155. <xsl:apply-templates select='node()[not(self::affiliation|self::authorblurb|self::doc:affiliation|self::doc:authorblurb)]'/>
  156. </xsl:template>
  157. <xsl:template match='abstract|doc:abstract'
  158. mode='doc:body'>
  159. <xsl:if test='title|doc:title'>
  160. <xsl:call-template name='doc:make-paragraph'>
  161. <xsl:with-param name='style' select='"abstract-title"'/>
  162. <xsl:with-param name='content'>
  163. <xsl:apply-templates select='title/node()|doc:title/node()'
  164. mode='doc:body'/>
  165. </xsl:with-param>
  166. </xsl:call-template>
  167. </xsl:if>
  168. <xsl:apply-templates select='*[not(self::title|self::doc:title)]'
  169. mode='doc:body'>
  170. <xsl:with-param name='class'>abstract</xsl:with-param>
  171. </xsl:apply-templates>
  172. </xsl:template>
  173. <!-- TODO -->
  174. <xsl:template match='authorblurb|personblurb |
  175. doc:authorblurb|doc:personblurb'
  176. mode='doc:body'/>
  177. <!-- TODO: handle inline markup (eg. emphasis) -->
  178. <xsl:template match='surname|firstname|honorific|lineage|othername|contrib|email|shortaffil|jobtitle|orgname|orgdiv|street|pob|postcode|city|state|country|phone|fax|citetitle |
  179. doc:surname|doc:firstname|doc:honorific|doc:lineage|doc:othername|doc:contrib|doc:email|doc:shortaffil|doc:jobtitle|doc:orgname|doc:orgdiv|doc:street|doc:pob|doc:postcode|doc:city|doc:state|doc:country|doc:phone|doc:fax|doc:citetitle'
  180. mode='doc:body'>
  181. <xsl:if test='preceding-sibling::*'>
  182. <xsl:call-template name='doc:make-phrase'>
  183. <xsl:with-param name='content'>
  184. <xsl:text> </xsl:text>
  185. </xsl:with-param>
  186. </xsl:call-template>
  187. </xsl:if>
  188. <xsl:call-template name='doc:handle-linebreaks'>
  189. <xsl:with-param name='style' select='local-name()'/>
  190. <xsl:with-param name='content' select='node()'/>
  191. </xsl:call-template>
  192. </xsl:template>
  193. <xsl:template match='email|doc:email'
  194. mode='doc:body'>
  195. <xsl:variable name='address'>
  196. <xsl:choose>
  197. <xsl:when test='starts-with(., "mailto:")'>
  198. <xsl:value-of select='.'/>
  199. </xsl:when>
  200. <xsl:otherwise>
  201. <xsl:text>mailto:</xsl:text>
  202. <xsl:value-of select='.'/>
  203. </xsl:otherwise>
  204. </xsl:choose>
  205. </xsl:variable>
  206. <xsl:call-template name='doc:make-hyperlink'>
  207. <xsl:with-param name='target' select='$address'/>
  208. <xsl:with-param name='content'>
  209. <xsl:call-template name='doc:handle-linebreaks'>
  210. <xsl:with-param name='style'>Hyperlink</xsl:with-param>
  211. </xsl:call-template>
  212. </xsl:with-param>
  213. </xsl:call-template>
  214. </xsl:template>
  215. <!-- otheraddr often contains ulink -->
  216. <xsl:template match='otheraddr|doc:otheraddr'
  217. mode='doc:body'>
  218. <xsl:choose>
  219. <xsl:when test='ulink|doc:ulink'>
  220. <xsl:for-each select='ulink|doc:ulink'>
  221. <xsl:variable name='prev'
  222. select='preceding-sibling::ulink[1] |
  223. preceding-sibling::doc:ulink[1]'/>
  224. <xsl:choose>
  225. <xsl:when test='$prev'>
  226. <xsl:for-each
  227. select='preceding-sibling::node()[generate-id(following-sibling::*[self::ulink|self::doc:ulink][1]) = generate-id(current())]'>
  228. <xsl:call-template name='doc:handle-linebreaks'>
  229. <xsl:with-param name='style'>otheraddr</xsl:with-param>
  230. </xsl:call-template>
  231. </xsl:for-each>
  232. </xsl:when>
  233. <xsl:when test='preceding-sibling::node()'>
  234. <xsl:call-template name='doc:handle-linebreaks'>
  235. <xsl:with-param name='style'>otheraddr</xsl:with-param>
  236. </xsl:call-template>
  237. </xsl:when>
  238. </xsl:choose>
  239. <xsl:apply-templates select='.'/>
  240. </xsl:for-each>
  241. <xsl:if test='*[self::ulink|self::doc:ulink][last()]/following-sibling::node()'>
  242. <xsl:call-template name='doc:handle-linebreaks'>
  243. <xsl:with-param name='content'
  244. select='*[self::ulink|self::doc:ulink][last()]/following-sibling::node()'/>
  245. <xsl:with-param name='style'>otheraddr</xsl:with-param>
  246. </xsl:call-template>
  247. </xsl:if>
  248. </xsl:when>
  249. <xsl:otherwise>
  250. <xsl:call-template name='doc:handle-linebreaks'>
  251. <xsl:with-param name='style'>otheraddr</xsl:with-param>
  252. </xsl:call-template>
  253. </xsl:otherwise>
  254. </xsl:choose>
  255. </xsl:template>
  256. <xsl:template match='ulink|doc:ulink'
  257. mode='doc:body'>
  258. <xsl:call-template name='doc:make-hyperlink'>
  259. <xsl:with-param name='target' select='@url'/>
  260. <xsl:with-param name='content'>
  261. <xsl:call-template name='doc:handle-linebreaks'>
  262. <xsl:with-param name='style'>Hyperlink</xsl:with-param>
  263. </xsl:call-template>
  264. </xsl:with-param>
  265. </xsl:call-template>
  266. </xsl:template>
  267. <!-- Cannot round-trip this element -->
  268. <xsl:template match='personname|doc:personname'
  269. mode='doc:body'>
  270. <xsl:apply-templates mode='doc:body'/>
  271. </xsl:template>
  272. <xsl:template match='releaseinfo|doc:releaseinfo'
  273. mode='doc:body'>
  274. <xsl:call-template name='doc:make-paragraph'>
  275. <xsl:with-param name='style'
  276. select='"releaseinfo"'/>
  277. </xsl:call-template>
  278. </xsl:template>
  279. <xsl:template match='para|doc:para'
  280. mode='doc:body'>
  281. <xsl:param name='class'/>
  282. <xsl:variable name='block'
  283. select='blockquote|calloutlist|classsynopsis|funcsynopsis|figure|glosslist|graphic|informalfigure|informaltable|itemizedlist|literallayout|mediaobject|mediaobjectco|note|caution|warning|important|tip|orderedlist|programlisting|revhistory|segmentedlist|simplelist|table|variablelist |
  284. doc:blockquote|doc:calloutlist|doc:classsynopsis|doc:funcsynopsis|doc:figure|doc:glosslist|doc:graphic|doc:informalfigure|doc:informaltable|doc:itemizedlist|doc:literallayout|doc:mediaobject|doc:mediaobjectco|doc:note|doc:caution|doc:warning|doc:important|doc:tip|doc:orderedlist|doc:programlisting|doc:revhistory|doc:segmentedlist|doc:simplelist|doc:table|doc:variablelist'/>
  285. <xsl:choose>
  286. <xsl:when test='$block'>
  287. <xsl:call-template name='doc:make-paragraph'>
  288. <xsl:with-param name='style'>
  289. <xsl:choose>
  290. <xsl:when test='$class != ""'>
  291. <xsl:value-of select='$class'/>
  292. </xsl:when>
  293. <xsl:otherwise>para</xsl:otherwise>
  294. </xsl:choose>
  295. </xsl:with-param>
  296. <xsl:with-param name='content'
  297. select='$block[1]/preceding-sibling::node()'/>
  298. </xsl:call-template>
  299. <xsl:for-each select='$block'>
  300. <xsl:apply-templates select='.'/>
  301. <xsl:call-template name='doc:make-paragraph'>
  302. <xsl:with-param name='style'>
  303. <xsl:choose>
  304. <xsl:when test='$class != ""'>
  305. <xsl:value-of select='$class'/>
  306. </xsl:when>
  307. <xsl:otherwise>Normal</xsl:otherwise>
  308. </xsl:choose>
  309. </xsl:with-param>
  310. <xsl:with-param name='content'
  311. select='following-sibling::node()[generate-id(preceding-sibling::*[self::blockquote|self::calloutlist|self::figure|self::glosslist|self::graphic|self::informalfigure|self::informaltable|self::itemizedlist|self::literallayout|self::mediaobject|self::mediaobjectco|self::note|self::caution|self::warning|self::important|self::tip|self::orderedlist|self::programlisting|self::revhistory|self::segmentedlist|self::simplelist|self::table|self::variablelist | self::doc:blockquote|self::doc:calloutlist|self::doc:figure|self::doc:glosslist|self::doc:graphic|self::doc:informalfigure|self::doc:informaltable|self::doc:itemizedlist|self::doc:literallayout|self::doc:mediaobject|self::doc:mediaobjectco|self::doc:note|self::doc:caution|self::doc:warning|self::doc:important|self::doc:tip|self::doc:orderedlist|self::doc:programlisting|self::doc:revhistory|self::doc:segmentedlist|self::doc:simplelist|self::doc:table|self::doc:variablelist][1]) = generate-id(current())]'/>
  312. </xsl:call-template>
  313. </xsl:for-each>
  314. </xsl:when>
  315. <xsl:otherwise>
  316. <xsl:call-template name='doc:make-paragraph'>
  317. <xsl:with-param name='style'>
  318. <xsl:choose>
  319. <xsl:when test='$class != ""'>
  320. <xsl:value-of select='$class'/>
  321. </xsl:when>
  322. <xsl:otherwise>Normal</xsl:otherwise>
  323. </xsl:choose>
  324. </xsl:with-param>
  325. </xsl:call-template>
  326. </xsl:otherwise>
  327. </xsl:choose>
  328. </xsl:template>
  329. <xsl:template match='simpara|doc:simpara'
  330. mode='doc:body'>
  331. <xsl:param name='class'/>
  332. <xsl:call-template name='doc:make-paragraph'>
  333. <xsl:with-param name='style'>
  334. <xsl:choose>
  335. <xsl:when test='$class != ""'>
  336. <xsl:value-of select='concat("sim-", $class)'/>
  337. </xsl:when>
  338. <xsl:otherwise>simpara</xsl:otherwise>
  339. </xsl:choose>
  340. </xsl:with-param>
  341. </xsl:call-template>
  342. </xsl:template>
  343. <xsl:template match='emphasis|doc:emphasis'
  344. mode='doc:body'>
  345. <xsl:call-template name='doc:make-phrase'>
  346. <xsl:with-param name='italic'>
  347. <xsl:choose>
  348. <xsl:when test='not(@role)'>1</xsl:when>
  349. <xsl:otherwise>0</xsl:otherwise>
  350. </xsl:choose>
  351. </xsl:with-param>
  352. <xsl:with-param name='bold'>
  353. <xsl:choose>
  354. <xsl:when test='@role = "bold" or @role = "strong"'>1</xsl:when>
  355. <xsl:otherwise>0</xsl:otherwise>
  356. </xsl:choose>
  357. </xsl:with-param>
  358. </xsl:call-template>
  359. </xsl:template>
  360. <xsl:template match='informalfigure|doc:informalfigure'
  361. mode='doc:body'>
  362. <xsl:if test='mediaobject/imageobject/imagedata |
  363. doc:mediaobject/doc:imageobject/doc:imagedata'>
  364. <xsl:call-template name='doc:make-paragraph'>
  365. <xsl:with-param name='style' select='"informalfigure-imagedata"'/>
  366. <xsl:with-param name='content'>
  367. <xsl:call-template name='doc:make-phrase'>
  368. <xsl:with-param name='style'/>
  369. <xsl:with-param name='content'>
  370. <xsl:apply-templates select='mediaobject/imageobject/imagedata/@fileref |
  371. doc:mediaobject/doc:imageobject/doc:imagedata/@fileref'
  372. mode='textonly'/>
  373. </xsl:with-param>
  374. </xsl:call-template>
  375. </xsl:with-param>
  376. </xsl:call-template>
  377. </xsl:if>
  378. <xsl:apply-templates select='caption|doc:caption'
  379. mode='doc:body'/>
  380. <xsl:for-each select='*[not(self::mediaobject|self::doc:mediaobject|self::caption|self::doc:caption)]'>
  381. <xsl:call-template name='doc:nomatch'/>
  382. </xsl:for-each>
  383. </xsl:template>
  384. <xsl:template match='mediaobject|mediaobjectco |
  385. doc:mediaobject|doc:mediaobjectco'
  386. mode='doc:body'>
  387. <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'/>
  388. <xsl:apply-templates select='objectinfo/subtitle|objectinfo/subtitle |
  389. doc:objectinfo/doc:subtitle|doc:objectinfo/doc:subtitle'/>
  390. <!-- TODO: indicate error for other children of objectinfo -->
  391. <xsl:apply-templates select='*[not(self::objectinfo|self::doc:objectinfo)]'/>
  392. </xsl:template>
  393. <xsl:template match='imageobject|imageobjectco|audioobject|videoobject |
  394. doc:imageobject|doc:imageobjectco|doc:audioobject|doc:videoobject'
  395. mode='doc:body'>
  396. <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'/>
  397. <xsl:apply-templates select='objectinfo/subtitle|doc:objectinfo/doc:subtitle'/>
  398. <!-- TODO: indicate error for other children of objectinfo -->
  399. <xsl:apply-templates select='areaspec|doc:areaspec'/>
  400. <xsl:choose>
  401. <xsl:when test='imagedata|audiodata|videodata |
  402. doc:imagedata|doc:audiodata|doc:videodata'>
  403. <xsl:call-template name='doc:make-paragraph'>
  404. <xsl:with-param name='style'
  405. select='concat(local-name(), "-", local-name(imagedata|audiodata|videodata|doc:imagedata|doc:audiodata|doc:videodata))'/>
  406. <xsl:with-param name='content'>
  407. <xsl:call-template name='doc:make-phrase'>
  408. <xsl:with-param name='content'>
  409. <xsl:apply-templates select='*/@fileref'
  410. mode='textonly'/>
  411. </xsl:with-param>
  412. </xsl:call-template>
  413. </xsl:with-param>
  414. </xsl:call-template>
  415. </xsl:when>
  416. <xsl:when test='self::imageobjectco/imageobject/imagedata |
  417. self::doc:imageobjectco/doc:imageobject/doc:imagedata'>
  418. <xsl:call-template name='doc:make-paragraph'>
  419. <xsl:with-param name='style'
  420. select='concat(local-name(), "-imagedata")'/>
  421. <xsl:with-param name='content'>
  422. <xsl:call-template name='doc:make-phrase'>
  423. <xsl:with-param name='content'>
  424. <xsl:apply-templates select='*/@fileref'
  425. mode='textonly'/>
  426. </xsl:with-param>
  427. </xsl:call-template>
  428. </xsl:with-param>
  429. </xsl:call-template>
  430. </xsl:when>
  431. </xsl:choose>
  432. <xsl:apply-templates select='calloutlist|doc:calloutlist'/>
  433. <xsl:for-each select='*[not(self::imageobject |
  434. self::imagedata |
  435. self::audiodata |
  436. self::videodata |
  437. self::areaspec |
  438. self::calloutlist |
  439. self::doc:imageobject |
  440. self::doc:imagedata |
  441. self::doc:audiodata |
  442. self::doc:videodata |
  443. self::doc:areaspec |
  444. self::doc:calloutlist)]'>
  445. <xsl:call-template name='doc:nomatch'/>
  446. </xsl:for-each>
  447. </xsl:template>
  448. <xsl:template match='textobject|doc:textobject'
  449. mode='doc:body'>
  450. <xsl:choose>
  451. <xsl:when test='objectinfo/title|objectinfo|subtitle |
  452. doc:objectinfo/doc:title|doc:objectinfo|doc:subtitle'>
  453. <xsl:apply-templates select='objectinfo/title|doc:objectinfo/doc:title'
  454. mode='doc:body'/>
  455. <xsl:apply-templates select='objectinfo/subtitle|doc:objectinfo/doc:subtitle'
  456. mode='doc:body'/>
  457. <!-- TODO: indicate error for other children of objectinfo -->
  458. </xsl:when>
  459. <!-- In a table, the table itself and the caption delimit the textobject -->
  460. <xsl:when test='ancestor::table |
  461. ancestor::doc:table |
  462. ancestor::informaltable |
  463. ancestor::doc:informaltable'/>
  464. <xsl:otherwise>
  465. <!-- synthesize a title so that the parent textobject
  466. can be recreated.
  467. -->
  468. <xsl:call-template name='doc:make-paragraph'>
  469. <xsl:with-param name='style' select='"textobject-title"'/>
  470. <xsl:with-param name='content'>
  471. <xsl:call-template name='doc:make-phrase'>
  472. <xsl:with-param name='content'>
  473. <xsl:text>Text Object </xsl:text>
  474. <xsl:number level='any'/>
  475. </xsl:with-param>
  476. </xsl:call-template>
  477. </xsl:with-param>
  478. </xsl:call-template>
  479. </xsl:otherwise>
  480. </xsl:choose>
  481. <xsl:apply-templates select='*[not(self::objectinfo|self::doc:objectinfo)]'
  482. mode='doc:body'/>
  483. </xsl:template>
  484. <xsl:template match='caption|doc:caption'
  485. mode='doc:body'>
  486. <xsl:choose>
  487. <xsl:when test='not(*)'>
  488. <xsl:call-template name='doc:make-paragraph'>
  489. <xsl:with-param name='style' select='"Caption"'/>
  490. <xsl:with-param name='content'>
  491. <xsl:apply-templates/>
  492. </xsl:with-param>
  493. </xsl:call-template>
  494. </xsl:when>
  495. <xsl:when test='not(text()) and
  496. count(*) = count(para|doc:para) and
  497. count(*) = 1'>
  498. <xsl:call-template name='doc:make-paragraph'>
  499. <xsl:with-param name='style' select='"caption"'/>
  500. <xsl:with-param name='content'>
  501. <xsl:apply-templates select='*/node()' mode='doc:body'/>
  502. </xsl:with-param>
  503. </xsl:call-template>
  504. </xsl:when>
  505. <xsl:when test='text()'>
  506. <!-- Not valid DocBook -->
  507. <xsl:call-template name='doc:nomatch'/>
  508. </xsl:when>
  509. <xsl:otherwise>
  510. <xsl:call-template name='doc:make-paragraph'>
  511. <xsl:with-param name='style' select='"Caption"'/>
  512. <xsl:with-param name='content'>
  513. <xsl:apply-templates select='*[self::para|self::doc:para][1]/node()'
  514. mode='doc:body'/>
  515. </xsl:with-param>
  516. </xsl:call-template>
  517. <xsl:for-each select='text()|*[not(self::para|self::doc:para)]|*[self::para|self::doc:para][position() != 1]'>
  518. <xsl:call-template name='doc:nomatch'/>
  519. </xsl:for-each>
  520. </xsl:otherwise>
  521. </xsl:choose>
  522. </xsl:template>
  523. <xsl:template match='area|areaspec|doc:area|doc:areaspec'
  524. mode='doc:body'>
  525. <xsl:call-template name='doc:make-paragraph'>
  526. <xsl:with-param name='style' select='local-name()'/>
  527. <xsl:with-param name='content'/>
  528. </xsl:call-template>
  529. </xsl:template>
  530. <xsl:template match='calloutlist|doc:calloutlist'
  531. mode='doc:body'>
  532. <xsl:apply-templates select='callout|doc:callout'/>
  533. </xsl:template>
  534. <xsl:template match='callout|doc:callout'
  535. mode='doc:body'>
  536. <xsl:call-template name='doc:make-paragraph'>
  537. <xsl:with-param name='style' select='"callout"'/>
  538. <xsl:with-param name='content'>
  539. <!-- Normally a para would be the first child of a callout -->
  540. <xsl:apply-templates select='*[1][self::para|self::doc:para]/node()'
  541. mode='list'/>
  542. </xsl:with-param>
  543. </xsl:call-template>
  544. <!-- This is to catch the case where a listitem's first child is not a paragraph.
  545. - We may not be able to represent this properly.
  546. -->
  547. <xsl:apply-templates select='*[1][not(self::para|self::doc:para)]'
  548. mode='list'/>
  549. <xsl:apply-templates select='*[position() != 1]'
  550. mode='list'/>
  551. </xsl:template>
  552. <xsl:template match='table|informaltable |
  553. doc:table|doc:informaltable'
  554. mode='doc:body'>
  555. <xsl:call-template name='doc:make-table'>
  556. <xsl:with-param name='columns'>
  557. <xsl:apply-templates select='tgroup/colspec|doc:tgroup/doc:colspec'
  558. mode='doc:column'/>
  559. </xsl:with-param>
  560. </xsl:call-template>
  561. <xsl:apply-templates select='textobject|doc:textobject'
  562. mode='doc:body'/>
  563. <xsl:choose>
  564. <xsl:when test='caption|doc:caption'>
  565. <xsl:apply-templates select='caption|doc:caption'
  566. mode='doc:body'/>
  567. </xsl:when>
  568. <xsl:when test='textobject|doc:textobject'>
  569. <!-- Synthesize a caption to delimit the textobject -->
  570. <xsl:call-template name='doc:make-paragraph'>
  571. <xsl:with-param name='style'>Caption</xsl:with-param>
  572. <xsl:with-param name='content'/>
  573. <xsl:with-param name='attributes.node' select='/..'/>
  574. </xsl:call-template>
  575. </xsl:when>
  576. </xsl:choose>
  577. </xsl:template>
  578. <xsl:template match='colspec|doc:colspec' mode='doc:column'>
  579. <xsl:variable name='width'>
  580. <xsl:choose>
  581. <xsl:when test='contains(@colwidth, "*")'>
  582. <!-- May need to resolve proportional width with other columns -->
  583. <xsl:value-of select='substring-before(@colwidth, "*")'/>
  584. </xsl:when>
  585. <xsl:otherwise>
  586. <xsl:value-of select='@colwidth'/>
  587. </xsl:otherwise>
  588. </xsl:choose>
  589. </xsl:variable>
  590. <xsl:call-template name='doc:make-column'>
  591. <xsl:with-param name='width' select='$width'/>
  592. </xsl:call-template>
  593. </xsl:template>
  594. <xsl:template match='colspec|doc:colspec' mode='doc:body'/>
  595. <xsl:template name='doc:repeat'>
  596. <xsl:param name='repeats' select='0'/>
  597. <xsl:param name='content'/>
  598. <xsl:if test='$repeats > 0'>
  599. <xsl:copy-of select='$content'/>
  600. <xsl:call-template name='doc:repeat'>
  601. <xsl:with-param name='repeats' select='$repeats - 1'/>
  602. <xsl:with-param name='content' select='$content'/>
  603. </xsl:call-template>
  604. </xsl:if>
  605. </xsl:template>
  606. <xsl:template match='tgroup|tbody|thead |
  607. doc:tgroup|doc:tbody|doc:thead'
  608. mode='doc:body'>
  609. <xsl:apply-templates mode='doc:body'/>
  610. </xsl:template>
  611. <xsl:template match='row|doc:row' mode='doc:body'>
  612. <xsl:call-template name='doc:make-table-row'>
  613. <xsl:with-param name='is-header' select='boolean(parent::thead|parent::doc:thead)'/>
  614. </xsl:call-template>
  615. </xsl:template>
  616. <xsl:template match='entry|doc:entry' mode='doc:body'>
  617. <!--
  618. Position = Sum(i,preceding-sibling[@colspan = ""]) + entry[i].@colspan)
  619. -->
  620. <xsl:variable name='position'>
  621. <xsl:call-template name='doc:sum-sibling'>
  622. <xsl:with-param name='sum' select='"1"'/>
  623. <xsl:with-param name='node' select='.'/>
  624. </xsl:call-template>
  625. </xsl:variable>
  626. <xsl:variable name='limit' select='$position + @colspan'/>
  627. <xsl:variable name='width.raw'>
  628. <xsl:choose>
  629. <xsl:when test='@colspan != ""'>
  630. <!-- Select all the colspec nodes which correspond to the
  631. column. That is all the nodes between the current
  632. column number and the column number plus the span.
  633. -->
  634. <xsl:variable name='combinedWidth'>
  635. <xsl:call-template name='doc:sum'>
  636. <xsl:with-param name='nodes' select='ancestor::*[self::table|self::doc:table|self::informaltable|self::doc:informaltable][1]/*[self::tgroup|self::doc:tgroup]/*[self::colspec|self::doc:colspec][not(position() &lt; $position) and position() &lt; $limit]'/>
  637. <xsl:with-param name='sum' select='"0"'/>
  638. </xsl:call-template>
  639. </xsl:variable>
  640. <xsl:value-of select='$combinedWidth'/>
  641. </xsl:when>
  642. <xsl:otherwise>
  643. <xsl:value-of select='ancestor::*[self::table|self::doc:table|self::informaltable|self::doc:informaltable][1]/*[self::tgroup|self::doc:tgroup]/*[self::colspec|self::doc:colspec][position() = $position]/@colwidth'/>
  644. </xsl:otherwise>
  645. </xsl:choose>
  646. </xsl:variable>
  647. <xsl:call-template name='doc:make-table-cell'>
  648. <xsl:with-param name='width'>
  649. <xsl:choose>
  650. <xsl:when test='contains($width.raw, "*")'>
  651. <!-- Select all the colspec nodes which correspond to the
  652. column. That is all the nodes between the current
  653. column number and the column number plus the span.
  654. -->
  655. <xsl:value-of select='substring-before($width.raw, "*")'/>
  656. </xsl:when>
  657. <xsl:otherwise>
  658. <xsl:value-of select='$width.raw'/>
  659. </xsl:otherwise>
  660. </xsl:choose>
  661. </xsl:with-param>
  662. <xsl:with-param name='hidden' select='@hidden'/>
  663. <xsl:with-param name='rowspan' select='@rowspan'/>
  664. <xsl:with-param name='colspan' select='@colspan'/>
  665. <xsl:with-param name='content'>
  666. <xsl:choose>
  667. <xsl:when test='not(para|doc:para)'>
  668. <!-- TODO: check for any block elements -->
  669. <xsl:call-template name='doc:make-paragraph'>
  670. <xsl:with-param name='style'/>
  671. <xsl:with-param name='attributes.node' select='/..'/>
  672. <xsl:with-param name='content'/>
  673. </xsl:call-template>
  674. </xsl:when>
  675. <xsl:otherwise>
  676. <xsl:apply-templates mode='doc:body'/>
  677. </xsl:otherwise>
  678. </xsl:choose>
  679. </xsl:with-param>
  680. </xsl:call-template>
  681. </xsl:template>
  682. <!-- Calculates the position by adding the
  683. count of the preceding siblings where they aren't colspans
  684. and adding the colspans of those entries which do.
  685. -->
  686. <xsl:template name='doc:sum-sibling'>
  687. <xsl:param name='sum'/>
  688. <xsl:param name='node'/>
  689. <xsl:variable name='add'>
  690. <xsl:choose>
  691. <xsl:when test='$node/preceding-sibling::*[self::entry|self::doc:entry]/@colspan != ""'>
  692. <xsl:value-of select='$node/preceding-sibling::*[self::entry|self::doc:entry]/@colspan'/>
  693. </xsl:when>
  694. <xsl:otherwise>
  695. <xsl:value-of select='"1"'/>
  696. </xsl:otherwise>
  697. </xsl:choose>
  698. </xsl:variable>
  699. <xsl:choose>
  700. <xsl:when test='count($node/preceding-sibling::*[self::entry|self::doc:entry]) &gt; 0'>
  701. <xsl:call-template name='doc:sum-sibling'>
  702. <xsl:with-param name='sum' select='$sum + $add'/>
  703. <xsl:with-param name='node'
  704. select='$node/preceding-sibling::*[self::entry|self::doc:entry][1]'/>
  705. </xsl:call-template>
  706. </xsl:when>
  707. <xsl:otherwise>
  708. <xsl:value-of select='$sum'/>
  709. </xsl:otherwise>
  710. </xsl:choose>
  711. </xsl:template>
  712. <xsl:template name='doc:sum'>
  713. <xsl:param name='sum' select='"0"'/>
  714. <xsl:param name='nodes'/>
  715. <xsl:variable name='tmpSum' select='$sum + $nodes[1]/@colwidth'/>
  716. <xsl:choose>
  717. <xsl:when test='count($nodes) &gt; 1'>
  718. <xsl:call-template name='doc:sum'>
  719. <xsl:with-param name='nodes' select='$nodes[position() != 1]'/>
  720. <xsl:with-param name='sum' select='$tmpSum'/>
  721. </xsl:call-template>
  722. </xsl:when>
  723. <xsl:otherwise>
  724. <xsl:value-of select='$tmpSum'/>
  725. </xsl:otherwise>
  726. </xsl:choose>
  727. </xsl:template>
  728. <xsl:template match='*[self::para|self::simpara|self::doc:para|self::doc:simpara]/text()[string-length(normalize-space(.)) != 0]'
  729. mode='doc:body'>
  730. <xsl:call-template name='doc:handle-linebreaks'/>
  731. </xsl:template>
  732. <xsl:template match='text()[not(parent::para|parent::simpara|parent::literallayout|parent::programlisting | parent::doc:para|parent::doc:simpara|parent::doc:literallayout|parent::doc:programlisting)][string-length(normalize-space(.)) != 0]'
  733. mode='doc:body'>
  734. <xsl:call-template name='doc:handle-linebreaks'/>
  735. </xsl:template>
  736. <xsl:template match='text()[string-length(normalize-space(.)) = 0]'
  737. mode='doc:body'/>
  738. <xsl:template match='literallayout/text()|programlisting/text() |
  739. doc:literallayout/text()|doc:programlisting/text()'
  740. mode='doc:body'>
  741. <xsl:call-template name='doc:handle-linebreaks'/>
  742. </xsl:template>
  743. <xsl:template name='doc:handle-linebreaks'>
  744. <xsl:param name='content' select='.'/>
  745. <xsl:param name='style'/>
  746. <xsl:choose>
  747. <xsl:when test='not($content)'/>
  748. <xsl:when test='contains($content, "&#xa;")'>
  749. <xsl:call-template name='doc:make-phrase'>
  750. <xsl:with-param name='style' select='$style'/>
  751. <xsl:with-param name='content'
  752. select='substring-before($content, "&#xa;")'/>
  753. </xsl:call-template>
  754. <xsl:call-template name='doc:handle-linebreaks-aux'>
  755. <xsl:with-param name='content'
  756. select='substring-after($content, "&#xa;")'/>
  757. <xsl:with-param name='style' select='$style'/>
  758. </xsl:call-template>
  759. </xsl:when>
  760. <xsl:otherwise>
  761. <xsl:call-template name='doc:make-phrase'>
  762. <xsl:with-param name='style' select='$style'/>
  763. <xsl:with-param name='content' select='$content'/>
  764. </xsl:call-template>
  765. </xsl:otherwise>
  766. </xsl:choose>
  767. </xsl:template>
  768. <!-- pre-condition: leading linefeed has been stripped -->
  769. <xsl:template name='doc:handle-linebreaks-aux'>
  770. <xsl:param name='content'/>
  771. <xsl:param name='style'/>
  772. <xsl:choose>
  773. <xsl:when test='contains($content, "&#xa;")'>
  774. <xsl:call-template name='doc:make-phrase'>
  775. <xsl:with-param name='style' select='$style'/>
  776. <xsl:with-param name='content'>
  777. <xsl:call-template name='doc:make-soft-break'/>
  778. <xsl:value-of select='substring-before($content, "&#xa;")'/>
  779. </xsl:with-param>
  780. </xsl:call-template>
  781. <xsl:call-template name='doc:handle-linebreaks-aux'>
  782. <xsl:with-param name='content'
  783. select='substring-after($content, "&#xa;")'/>
  784. <xsl:with-param name='style' select='$style'/>
  785. </xsl:call-template>
  786. </xsl:when>
  787. <xsl:otherwise>
  788. <xsl:call-template name='doc:make-phrase'>
  789. <xsl:with-param name='style' select='$style'/>
  790. <xsl:with-param name='content'>
  791. <xsl:call-template name='doc:make-soft-break'/>
  792. <xsl:value-of select='$content'/>
  793. </xsl:with-param>
  794. </xsl:call-template>
  795. </xsl:otherwise>
  796. </xsl:choose>
  797. </xsl:template>
  798. <xsl:template match='authorblurb|formalpara|legalnotice|note|caution|warning|important|tip |
  799. doc:authorblurb|doc:formalpara|doc:legalnotice|doc:note|doc:caution|doc:warning|doc:important|doc:tip'
  800. mode='doc:body'>
  801. <xsl:apply-templates select='*'>
  802. <xsl:with-param name='class'>
  803. <xsl:value-of select='local-name()'/>
  804. </xsl:with-param>
  805. </xsl:apply-templates>
  806. </xsl:template>
  807. <xsl:template match='blockquote|doc:blockquote'
  808. mode='doc:body'>
  809. <xsl:apply-templates select='blockinfo|title|doc:info|doc:title'
  810. mode='doc:body'>
  811. <xsl:with-param name='class'>
  812. <xsl:value-of select='local-name()'/>
  813. </xsl:with-param>
  814. </xsl:apply-templates>
  815. <xsl:apply-templates select='*[not(self::blockinfo|self::title|self::attribution|self::doc:info|self::doc:title|self::doc:attribution)]'
  816. mode='doc:body'>
  817. <xsl:with-param name='class' select='"blockquote"'/>
  818. </xsl:apply-templates>
  819. <xsl:if test='attribution|doc:attribution'>
  820. <xsl:call-template name='doc:make-paragraph'>
  821. <xsl:with-param name='style' select='"blockquote-attribution"'/>
  822. <xsl:with-param name='content'>
  823. <xsl:call-template name='doc:make-phrase'>
  824. <xsl:with-param name='content'>
  825. <xsl:apply-templates select='attribution/node()|doc:attribution/node()'/>
  826. </xsl:with-param>
  827. </xsl:call-template>
  828. </xsl:with-param>
  829. </xsl:call-template>
  830. </xsl:if>
  831. </xsl:template>
  832. <xsl:template match='literallayout|programlisting|doc:literallayout|doc:programlisting'
  833. mode='doc:body'>
  834. <xsl:param name='class'/>
  835. <xsl:call-template name='doc:make-paragraph'>
  836. <xsl:with-param name='style' select='local-name()'/>
  837. </xsl:call-template>
  838. </xsl:template>
  839. <xsl:template match='bridgehead|doc:bridgehead'
  840. mode='doc:body'>
  841. <xsl:call-template name='doc:make-paragraph'>
  842. <xsl:with-param name='style' select='"bridgehead"'/>
  843. </xsl:call-template>
  844. </xsl:template>
  845. <xsl:template match='itemizedlist|orderedlist |
  846. doc:itemizedlist|doc:orderedlist'
  847. mode='doc:body'>
  848. <xsl:apply-templates select='listitem|doc:listitem'
  849. mode='doc:body'/>
  850. </xsl:template>
  851. <xsl:template match='listitem|doc:listitem'
  852. mode='doc:body'>
  853. <xsl:call-template name='doc:make-paragraph'>
  854. <xsl:with-param name='style'
  855. select='concat(local-name(..),
  856. count(ancestor::itemizedlist|ancestor::orderedlist|ancestor::doc:itemizedlist|ancestor::doc:orderedlist))'/>
  857. <xsl:with-param name='is-listitem' select='true()'/>
  858. <xsl:with-param name='content'>
  859. <!-- Normally a para would be the first child of a listitem -->
  860. <xsl:apply-templates select='*[1][self::para|self::doc:para]/node()'
  861. mode='doc:body'/>
  862. </xsl:with-param>
  863. </xsl:call-template>
  864. <!-- This is to catch the case where a listitem's first child is not a paragraph.
  865. - We may not be able to represent this properly.
  866. -->
  867. <xsl:apply-templates select='*[1][not(self::para|self::doc:para)]'
  868. mode='doc:list-continue'/>
  869. <xsl:apply-templates select='*[position() != 1]'
  870. mode='doc:list-continue'/>
  871. </xsl:template>
  872. <xsl:template match='para|doc:para' mode='doc:list-continue'>
  873. <xsl:apply-templates select='.'
  874. mode='doc:body'>
  875. <xsl:with-param name='class' select='"para-continue"'/>
  876. </xsl:apply-templates>
  877. </xsl:template>
  878. <!-- non-paragraph elements in a listitem are rolled back into
  879. the list item upon conversion.
  880. -->
  881. <xsl:template match='*' mode='doc:list-continue'>
  882. <xsl:apply-templates select='.' mode='doc:body'/>
  883. </xsl:template>
  884. <xsl:template match='variablelist|doc:variablelist'
  885. mode='doc:body'>
  886. <xsl:apply-templates select='*[not(self::varlistentry|self::doc:varlistentry)]'/>
  887. <xsl:call-template name='doc:make-table'>
  888. <xsl:with-param name='columns'>
  889. <xsl:call-template name='doc:make-column'>
  890. <xsl:with-param name='width' select='"1"'/>
  891. </xsl:call-template>
  892. <xsl:call-template name='doc:make-column'>
  893. <xsl:with-param name='width' select='"3"'/>
  894. </xsl:call-template>
  895. </xsl:with-param>
  896. <xsl:with-param name='rows'>
  897. <xsl:apply-templates select='varlistentry|doc:varlistentry'/>
  898. </xsl:with-param>
  899. </xsl:call-template>
  900. </xsl:template>
  901. <xsl:template match='varlistentry|doc:varlistentry'
  902. mode='doc:body'>
  903. <xsl:call-template name='doc:make-table-row'>
  904. <xsl:with-param name='content'>
  905. <xsl:call-template name='doc:make-table-cell'>
  906. <xsl:with-param name='content'>
  907. <xsl:call-template name='doc:make-paragraph'>
  908. <xsl:with-param name='style' select='"variablelist-term"'/>
  909. <xsl:with-param name='content'>
  910. <xsl:apply-templates select='*[self::term|self::doc:term][1]/node()'
  911. mode='doc:body'/>
  912. <xsl:for-each select='*[self::term|self::doc:term][position() != 1]'>
  913. <xsl:call-template name='doc:make-phrase'>
  914. <xsl:with-param name='content'>
  915. <xsl:call-template name='doc:make-soft-break'/>
  916. </xsl:with-param>
  917. </xsl:call-template>
  918. <xsl:apply-templates/>
  919. </xsl:for-each>
  920. </xsl:with-param>
  921. </xsl:call-template>
  922. </xsl:with-param>
  923. </xsl:call-template>
  924. <xsl:call-template name='doc:make-table-cell'>
  925. <xsl:with-param name='content'>
  926. <xsl:apply-templates select='listitem/node()|doc:listitem/node()'
  927. mode='doc:body'/>
  928. </xsl:with-param>
  929. </xsl:call-template>
  930. </xsl:with-param>
  931. </xsl:call-template>
  932. </xsl:template>
  933. <!-- These elements are not displayed.
  934. - However, they may need to be added (perhaps as hidden text)
  935. - for round-tripping.
  936. -->
  937. <xsl:template match='anchor|areaset|audiodata|audioobject|
  938. beginpage|
  939. constraint|
  940. indexterm|itermset|
  941. keywordset|
  942. msg |
  943. doc:anchor|doc:areaset|doc:audiodata|doc:audioobject|
  944. doc:beginpage|
  945. doc:constraint|
  946. doc:indexterm|doc:itermset|
  947. doc:keywordset|
  948. doc:msg'
  949. mode='doc:body'/>
  950. <xsl:template match='*' name='doc:nomatch'>
  951. <xsl:param name='node' select='.'/>
  952. <xsl:message>
  953. <xsl:value-of select='local-name($node)'/>
  954. <xsl:if test='namespace-uri($node) != ""'>
  955. <xsl:text> [</xsl:text>
  956. <xsl:value-of select='namespace-uri($node)'/>
  957. <xsl:text>]</xsl:text>
  958. </xsl:if>
  959. <xsl:text> encountered</xsl:text>
  960. <xsl:if test='$node/parent::*'>
  961. <xsl:text> in </xsl:text>
  962. <xsl:value-of select='local-name($node/parent::*)'/>
  963. </xsl:if>
  964. <xsl:text>, but no template matches.</xsl:text>
  965. </xsl:message>
  966. <xsl:for-each select='$node'>
  967. <xsl:choose>
  968. <xsl:when test='self::abstract |
  969. self::ackno |
  970. self::address |
  971. self::answer |
  972. self::appendix |
  973. self::artheader |
  974. self::authorgroup |
  975. self::bibliodiv |
  976. self::biblioentry |
  977. self::bibliography |
  978. self::bibliomixed |
  979. self::bibliomset |
  980. self::biblioset |
  981. self::bridgehead |
  982. self::calloutlist |
  983. self::caption |
  984. self::classsynopsis |
  985. self::colophon |
  986. self::constraintdef |
  987. self::copyright |
  988. self::dedication |
  989. self::epigraph |
  990. self::equation |
  991. self::example |
  992. self::figure |
  993. self::funcsynopsis |
  994. self::glossary |
  995. self::glossdef |
  996. self::glossdiv |
  997. self::glossentry |
  998. self::glosslist |
  999. self::graphic |
  1000. self::highlights |
  1001. self::imageobject |
  1002. self::imageobjectco |
  1003. self::index |
  1004. self::indexdiv |
  1005. self::indexentry |
  1006. self::informalequation |
  1007. self::informalexample |
  1008. self::informalfigure |
  1009. self::lot |
  1010. self::lotentry |
  1011. self::mediaobject |
  1012. self::mediaobjectco |
  1013. self::member |
  1014. self::msgentry |
  1015. self::msgset |
  1016. self::part |
  1017. self::partintro |
  1018. self::personblurb |
  1019. self::preface |
  1020. self::printhistory |
  1021. self::procedure |
  1022. self::programlisting |
  1023. self::programlistingco |
  1024. self::publisher |
  1025. self::qandadiv |
  1026. self::qandaentry |
  1027. self::qandaset |
  1028. self::question |
  1029. self::refdescriptor |
  1030. self::refentry |
  1031. self::refentrytitle |
  1032. self::reference |
  1033. self::refmeta |
  1034. self::refname |
  1035. self::refnamediv |
  1036. self::refpurpose |
  1037. self::refsect1 |
  1038. self::refsect2 |
  1039. self::refsect3 |
  1040. self::refsection |
  1041. self::refsynopsisdiv |
  1042. self::screen |
  1043. self::screenco |
  1044. self::screenshot |
  1045. self::seg |
  1046. self::seglistitem |
  1047. self::segmentedlist |
  1048. self::segtitle |
  1049. self::set |
  1050. self::setindex |
  1051. self::sidebar |
  1052. self::simplelist |
  1053. self::simplemsgentry |
  1054. self::step |
  1055. self::stepalternatives |
  1056. self::subjectset |
  1057. self::substeps |
  1058. self::task |
  1059. self::textobject |
  1060. self::toc |
  1061. self::videodata |
  1062. self::videoobject |
  1063. self::doc:abstract |
  1064. self::doc:ackno |
  1065. self::doc:address |
  1066. self::doc:answer |
  1067. self::doc:appendix |
  1068. self::doc:artheader |
  1069. self::doc:authorgroup |
  1070. self::doc:bibliodiv |
  1071. self::doc:biblioentry |
  1072. self::doc:bibliography |
  1073. self::doc:bibliomixed |
  1074. self::doc:bibliomset |
  1075. self::doc:biblioset |
  1076. self::doc:bridgehead |
  1077. self::doc:calloutlist |
  1078. self::doc:caption |
  1079. self::doc:classsynopsis |
  1080. self::doc:colophon |
  1081. self::doc:constraintdef |
  1082. self::doc:copyright |
  1083. self::doc:dedication |
  1084. self::doc:epigraph |
  1085. self::doc:equation |
  1086. self::doc:example |
  1087. self::doc:figure |
  1088. self::doc:funcsynopsis |
  1089. self::doc:glossary |
  1090. self::doc:glossdef |
  1091. self::doc:glossdiv |
  1092. self::doc:glossentry |
  1093. self::doc:glosslist |
  1094. self::doc:graphic |
  1095. self::doc:highlights |
  1096. self::doc:imageobject |
  1097. self::doc:imageobjectco |
  1098. self::doc:index |
  1099. self::doc:indexdiv |
  1100. self::doc:indexentry |
  1101. self::doc:informalequation |
  1102. self::doc:informalexample |
  1103. self::doc:informalfigure |
  1104. self::doc:lot |
  1105. self::doc:lotentry |
  1106. self::doc:mediaobject |
  1107. self::doc:mediaobjectco |
  1108. self::doc:member |
  1109. self::doc:msgentry |
  1110. self::doc:msgset |
  1111. self::doc:part |
  1112. self::doc:partintro |
  1113. self::doc:personblurb |
  1114. self::doc:preface |
  1115. self::doc:printhistory |
  1116. self::doc:procedure |
  1117. self::doc:programlisting |
  1118. self::doc:programlistingco |
  1119. self::doc:publisher |
  1120. self::doc:qandadiv |
  1121. self::doc:qandaentry |
  1122. self::doc:qandaset |
  1123. self::doc:question |
  1124. self::doc:refdescriptor |
  1125. self::doc:refentry |
  1126. self::doc:refentrytitle |
  1127. self::doc:reference |
  1128. self::doc:refmeta |
  1129. self::doc:refname |
  1130. self::doc:refnamediv |
  1131. self::doc:refpurpose |
  1132. self::doc:refsect1 |
  1133. self::doc:refsect2 |
  1134. self::doc:refsect3 |
  1135. self::doc:refsection |
  1136. self::doc:refsynopsisdiv |
  1137. self::doc:screen |
  1138. self::doc:screenco |
  1139. self::doc:screenshot |
  1140. self::doc:seg |
  1141. self::doc:seglistitem |
  1142. self::doc:segmentedlist |
  1143. self::doc:segtitle |
  1144. self::doc:set |
  1145. self::doc:setindex |
  1146. self::doc:sidebar |
  1147. self::doc:simplelist |
  1148. self::doc:simplemsgentry |
  1149. self::doc:step |
  1150. self::doc:stepalternatives |
  1151. self::doc:subjectset |
  1152. self::doc:substeps |
  1153. self::doc:task |
  1154. self::doc:textobject |
  1155. self::doc:toc |
  1156. self::doc:videodata |
  1157. self::doc:videoobject |
  1158. self::*[not(starts-with(local-name(), "informal")) and contains(local-name(), "info")]'>
  1159. <xsl:call-template name='doc:make-paragraph'>
  1160. <xsl:with-param name='style' select='"blockerror"'/>
  1161. <xsl:with-param name='content'>
  1162. <xsl:call-template name='doc:make-phrase'>
  1163. <xsl:with-param name='content'>
  1164. <xsl:value-of select='local-name()'/>
  1165. <xsl:if test='namespace-uri() != ""'>
  1166. <xsl:text> [</xsl:text>
  1167. <xsl:value-of select='namespace-uri()'/>
  1168. <xsl:text>]</xsl:text>
  1169. </xsl:if>
  1170. <xsl:text> encountered</xsl:text>
  1171. <xsl:if test='parent::*'>
  1172. <xsl:text> in </xsl:text>
  1173. <xsl:value-of select='local-name(parent::*)'/>
  1174. </xsl:if>
  1175. <xsl:text>, but no template matches.</xsl:text>
  1176. </xsl:with-param>
  1177. </xsl:call-template>
  1178. </xsl:with-param>
  1179. </xsl:call-template>
  1180. </xsl:when>
  1181. <!-- Some elements are sometimes blocks, sometimes inline
  1182. <xsl:when test='self::affiliation |
  1183. self::alt |
  1184. self::attribution |
  1185. self::collab |
  1186. self::collabname |
  1187. self::confdates |
  1188. self::confgroup |
  1189. self::confnum |
  1190. self::confsponsor |
  1191. self::conftitle |
  1192. self::contractnum |
  1193. self::contractsponsor |
  1194. self::contrib |
  1195. self::corpauthor |
  1196. self::corpcredit |
  1197. self::corpname |
  1198. self::edition |
  1199. self::editor |
  1200. self::jobtitle |
  1201. self::personname |
  1202. self::publishername |
  1203. self::remark |
  1204. self::doc:affiliation |
  1205. self::doc:alt |
  1206. self::doc:attribution |
  1207. self::doc:collab |
  1208. self::doc:collabname |
  1209. self::doc:confdates |
  1210. self::doc:confgroup |
  1211. self::doc:confnum |
  1212. self::doc:confsponsor |
  1213. self::doc:conftitle |
  1214. self::doc:contractnum |
  1215. self::doc:contractsponsor |
  1216. self::doc:contrib |
  1217. self::doc:corpauthor |
  1218. self::doc:corpcredit |
  1219. self::doc:corpname |
  1220. self::doc:edition |
  1221. self::doc:editor |
  1222. self::doc:jobtitle |
  1223. self::doc:personname |
  1224. self::doc:publishername |
  1225. self::doc:remark'>
  1226. </xsl:when>
  1227. -->
  1228. <xsl:otherwise>
  1229. <xsl:call-template name='doc:make-phrase'>
  1230. <xsl:with-param name='style' select='"inlineerror"'/>
  1231. <xsl:with-param name='content'>
  1232. <xsl:value-of select='local-name()'/>
  1233. <xsl:text> encountered</xsl:text>
  1234. <xsl:if test='parent::*'>
  1235. <xsl:text> in </xsl:text>
  1236. <xsl:value-of select='local-name(parent::*)'/>
  1237. </xsl:if>
  1238. <xsl:text>, but no template matches.</xsl:text>
  1239. </xsl:with-param>
  1240. </xsl:call-template>
  1241. </xsl:otherwise>
  1242. </xsl:choose>
  1243. </xsl:for-each>
  1244. </xsl:template>
  1245. <xsl:template match='*' mode='doc:copy'>
  1246. <xsl:copy>
  1247. <xsl:apply-templates select='@*' mode='doc:copy'/>
  1248. <xsl:apply-templates mode='doc:copy'/>
  1249. </xsl:copy>
  1250. </xsl:template>
  1251. <xsl:template match='@*' mode='doc:copy'>
  1252. <xsl:copy/>
  1253. </xsl:template>
  1254. <!-- Stubs: the importing stylesheet must override these -->
  1255. <!-- stub template for creating a paragraph -->
  1256. <xsl:template name='doc:make-paragraph'>
  1257. </xsl:template>
  1258. <!-- stub template for creating a phrase -->
  1259. <xsl:template name='doc:make-phrase'>
  1260. </xsl:template>
  1261. <!-- stub template for inserting attributes -->
  1262. <xsl:template name='doc:attributes'/>
  1263. <!-- emit a message -->
  1264. <xsl:template name='doc:warning'>
  1265. <xsl:param name='message'/>
  1266. <xsl:message>WARNING: <xsl:value-of select='$message'/></xsl:message>
  1267. </xsl:template>
  1268. </xsl:stylesheet>