problem in converting HTML to PDF using tidy

Reply

Join Date: Nov 2008
Posts: 27
Reputation: jaiprakash15 is an unknown quantity at this point 
Solved Threads: 0
jaiprakash15 jaiprakash15 is offline Offline
Light Poster

problem in converting HTML to PDF using tidy

 
0
  #1
May 16th, 2009
Dear Friends,

am working on a project where i have to convert the HTML file to a PDF file. am using tidy and fop methods for converting. am not good at XSL style sheet.

when i try to run the program by giving the input file (39.html) to ma program it is giving error as table attributes "summary" not found. but if i give also it is adding the table. please help. find the java program, html file and xsl file below

When i run the program it showing table attributes "summary" is missing.. please help

PdfCreating.java
  1.  
  2. import java.io.IOException;
  3.  
  4. import java.io.*;
  5.  
  6. import java.util.List;
  7.  
  8. import java.util.Set;
  9.  
  10. import java.util.LinkedHashSet;
  11.  
  12.  
  13.  
  14. import java.io.FileInputStream;
  15.  
  16. import java.io.File;
  17.  
  18. import java.io.FileOutputStream;
  19.  
  20. import java.io.OutputStream;
  21.  
  22. import java.io.ByteArrayOutputStream;
  23.  
  24.  
  25.  
  26. import javax.xml.parsers.DocumentBuilder;
  27.  
  28. import javax.xml.parsers.DocumentBuilderFactory;
  29.  
  30. import javax.xml.transform.Transformer;
  31.  
  32. import javax.xml.transform.TransformerFactory;
  33.  
  34.  
  35.  
  36. import org.apache.xalan.*;
  37.  
  38. import org.apache.xalan.serialize.*;
  39.  
  40.  
  41.  
  42. import org.apache.xalan.res.*;
  43.  
  44. import org.apache.xalan.xslt.*;
  45.  
  46. import javax.xml.transform.dom.DOMResult;
  47.  
  48. import javax.xml.transform.dom.DOMSource;
  49.  
  50.  
  51.  
  52. import org.w3c.tidy.Tidy;
  53.  
  54. import org.w3c.dom.Document;
  55.  
  56. import org.apache.fop.apps.*;
  57.  
  58.  
  59.  
  60. import org.apache.fop.apps.Driver;
  61.  
  62.  
  63.  
  64. import org.apache.fop.tools.DocumentInputSource;
  65.  
  66. import org.apache.fop.image.*;
  67.  
  68.  
  69.  
  70. import org.apache.avalon.framework.logger.ConsoleLogger;
  71.  
  72. import org.apache.avalon.framework.logger.Logger;
  73.  
  74.  
  75. public class PdfCreating{
  76. static Set pdfFilesList = null;
  77.  
  78. public static void main(String[] args)throws IOException{
  79.  
  80.  
  81. pdfFilesList = new LinkedHashSet();
  82. System.out.println("Sample test");
  83. String htmlfname = "39.html";
  84.  
  85. html2PDF(htmlfname);
  86.  
  87. }
  88.  
  89. private static void html2PDF(String htmlFileName) {
  90.  
  91.  
  92.  
  93. FileInputStream input = null;
  94.  
  95.  
  96.  
  97. String fileName = htmlFileName;
  98.  
  99.  
  100.  
  101. try {
  102.  
  103. input = new FileInputStream(htmlFileName);
  104.  
  105. } catch (java.io.FileNotFoundException e) {
  106.  
  107. System.out.println("File not found: " + htmlFileName);
  108.  
  109. }
  110.  
  111.  
  112.  
  113. Tidy tidy = new Tidy();
  114.  
  115. Document xmlDoc = tidy.parseDOM(input, null);
  116.  
  117. Document foDoc = xml2FO(xmlDoc, "xhtml2fo.xsl");
  118.  
  119.  
  120.  
  121. String pdfFileName = htmlFileName.substring(0, htmlFileName.indexOf(".")) + ".pdf";
  122.  
  123.  
  124.  
  125. pdfFilesList.add(pdfFileName);
  126.  
  127.  
  128.  
  129. try {
  130.  
  131. OutputStream pdf = new FileOutputStream(new File(pdfFileName));
  132.  
  133. pdf.write(fo2PDF(foDoc));
  134.  
  135. pdf.flush();
  136.  
  137. pdf.close();
  138.  
  139. input.close();
  140.  
  141. } catch (java.io.FileNotFoundException e) {
  142.  
  143. System.out.println("Error creating PDF: " + pdfFileName);
  144.  
  145. } catch (java.io.IOException e) {
  146.  
  147. System.out.println("Error writing PDF: " + pdfFileName);
  148.  
  149. }
  150.  
  151.  
  152.  
  153. }
  154.  
  155.  
  156.  
  157. private static byte[] fo2PDF(Document foDocument) {
  158.  
  159.  
  160.  
  161. DocumentInputSource fopInputSource = new DocumentInputSource(foDocument);
  162.  
  163. try {
  164.  
  165. ByteArrayOutputStream out = new ByteArrayOutputStream();
  166.  
  167. Logger log = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
  168.  
  169.  
  170.  
  171. Driver driver = new Driver(fopInputSource, out);
  172.  
  173. driver.setLogger(log);
  174.  
  175. driver.setRenderer(Driver.RENDER_PDF);
  176.  
  177. driver.run();
  178.  
  179.  
  180.  
  181. return out.toByteArray();
  182.  
  183.  
  184.  
  185. } catch (Exception ex) {
  186.  
  187. System.out.println("Exception in fo2PDF==>"+ex);
  188.  
  189. ex.printStackTrace();
  190.  
  191. return null;
  192.  
  193. }
  194.  
  195. }
  196.  
  197. private static Document xml2FO(Document xml, String styleSheet) {
  198.  
  199.  
  200.  
  201. DOMSource xmlDomSource = new DOMSource(xml);
  202.  
  203. DOMResult domResult = new DOMResult();
  204.  
  205. Transformer transformer = null;
  206.  
  207.  
  208.  
  209. transformer = getTransformer(styleSheet);
  210.  
  211.  
  212.  
  213. if (transformer == null) {
  214.  
  215. System.out.println("Error creating transformer for " + styleSheet);
  216.  
  217. System.exit(1);
  218.  
  219. }
  220.  
  221. try {
  222.  
  223.  
  224.  
  225. transformer.transform(xmlDomSource, domResult);
  226.  
  227.  
  228.  
  229. } catch (javax.xml.transform.TransformerException e) {
  230.  
  231. System.out.println("Error XML" + e);
  232.  
  233. return null;
  234.  
  235. }
  236.  
  237. return (Document) domResult.getNode();
  238.  
  239. }
  240.  
  241. private static Transformer getTransformer(String styleSheet) {
  242.  
  243. try {
  244.  
  245.  
  246.  
  247. TransformerFactory tFactory = TransformerFactory.newInstance();
  248.  
  249. DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
  250.  
  251.  
  252.  
  253. dFactory.setNamespaceAware(true);
  254.  
  255.  
  256.  
  257. DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
  258.  
  259. Document xslDoc = dBuilder.parse(styleSheet);
  260.  
  261. DOMSource xslDomSource = new DOMSource(xslDoc);
  262.  
  263.  
  264.  
  265. return tFactory.newTransformer(xslDomSource);
  266.  
  267.  
  268.  
  269. } catch (javax.xml.transform.TransformerException e) {
  270.  
  271. System.out.println("Error " + e);
  272.  
  273. e.printStackTrace();
  274.  
  275. return null;
  276.  
  277. } catch (java.io.IOException e) {
  278.  
  279. System.out.println("Error " + e);
  280.  
  281. e.printStackTrace();
  282.  
  283. return null;
  284.  
  285. } catch (javax.xml.parsers.ParserConfigurationException e) {
  286.  
  287. System.out.println("Error " + e);
  288.  
  289. e.printStackTrace();
  290.  
  291. return null;
  292.  
  293. } catch (org.xml.sax.SAXException e) {
  294.  
  295. System.out.println("Error " + e);
  296.  
  297. e.printStackTrace();
  298.  
  299. return null;
  300.  
  301. }
  302.  
  303.  
  304.  
  305. }
  306.  
  307. }

xhtml2fo.xsl file

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0"
  3.  
  4. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  5.  
  6. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  7.  
  8. xmlns:html="http://www.w3.org/1999/xhtml">
  9.  
  10.  
  11.  
  12. <xsl:output method="xml"
  13.  
  14. version="1.0"
  15.  
  16. encoding="UTF-8"
  17.  
  18. indent="no"/>
  19.  
  20.  
  21.  
  22. <!--======================================================================
  23.  
  24. Parameters
  25.  
  26. =======================================================================-->
  27.  
  28.  
  29.  
  30. <!-- page size -->
  31.  
  32. <xsl:param name="page-width">auto</xsl:param>
  33.  
  34. <xsl:param name="page-height">auto</xsl:param>
  35.  
  36. <xsl:param name="page-margin-top">1in</xsl:param>
  37.  
  38. <xsl:param name="page-margin-bottom">1in</xsl:param>
  39.  
  40. <xsl:param name="page-margin-left">1in</xsl:param>
  41.  
  42. <xsl:param name="page-margin-right">1in</xsl:param>
  43.  
  44.  
  45.  
  46. <!-- page header and footer -->
  47.  
  48. <xsl:param name="page-header-margin">0.5in</xsl:param>
  49.  
  50. <xsl:param name="page-footer-margin">0.5in</xsl:param>
  51.  
  52. <xsl:param name="title-print-in-header">true</xsl:param>
  53.  
  54. <xsl:param name="page-number-print-in-footer">true</xsl:param>
  55.  
  56.  
  57.  
  58. <!-- multi column -->
  59.  
  60. <xsl:param name="column-count">1</xsl:param>
  61.  
  62. <xsl:param name="column-gap">12pt</xsl:param>
  63.  
  64.  
  65.  
  66. <!-- writing-mode: lr-tb | rl-tb | tb-rl -->
  67.  
  68. <xsl:param name="writing-mode">lr-tb</xsl:param>
  69.  
  70.  
  71.  
  72. <!-- text-align: justify | start -->
  73.  
  74. <xsl:param name="text-align">start</xsl:param>
  75.  
  76.  
  77.  
  78. <!-- hyphenate: true | false -->
  79.  
  80. <xsl:param name="hyphenate">false</xsl:param>
  81.  
  82.  
  83.  
  84.  
  85.  
  86. <!--======================================================================
  87.  
  88. Attribute Sets
  89.  
  90. =======================================================================-->
  91.  
  92.  
  93.  
  94. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  95.  
  96. Root
  97.  
  98. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  99.  
  100.  
  101.  
  102. <xsl:attribute-set name="root">
  103.  
  104. <xsl:attribute name="writing-mode"><xsl:value-of select="$writing-mode"/></xsl:attribute>
  105.  
  106. <xsl:attribute name="hyphenate"><xsl:value-of select="$hyphenate"/></xsl:attribute>
  107.  
  108. <xsl:attribute name="text-align"><xsl:value-of select="$text-align"/></xsl:attribute>
  109.  
  110. <!-- specified on fo:root to change the properties' initial values -->
  111.  
  112. </xsl:attribute-set>
  113.  
  114.  
  115.  
  116. <xsl:attribute-set name="page">
  117.  
  118. <xsl:attribute name="page-width"><xsl:value-of select="$page-width"/></xsl:attribute>
  119.  
  120. <xsl:attribute name="page-height"><xsl:value-of select="$page-height"/></xsl:attribute>
  121.  
  122. <!-- specified on fo:simple-page-master -->
  123.  
  124. </xsl:attribute-set>
  125.  
  126.  
  127.  
  128. <xsl:attribute-set name="body">
  129. <xsl:attribute name="background-color">yellow</xsl:attribute>
  130.  
  131. <!-- specified on fo:flow's only child fo:block -->
  132.  
  133. </xsl:attribute-set>
  134.  
  135.  
  136.  
  137. <xsl:attribute-set name="page-header">
  138.  
  139. <!-- specified on (page-header)fo:static-content's only child fo:block -->
  140.  
  141. <xsl:attribute name="font-size">small</xsl:attribute>
  142.  
  143. <xsl:attribute name="text-align">center</xsl:attribute>
  144.  
  145. </xsl:attribute-set>
  146.  
  147.  
  148.  
  149. <xsl:attribute-set name="page-footer">
  150.  
  151. <!-- specified on (page-footer)fo:static-content's only child fo:block -->
  152.  
  153. <xsl:attribute name="font-size">small</xsl:attribute>
  154.  
  155. <xsl:attribute name="text-align">center</xsl:attribute>
  156.  
  157. </xsl:attribute-set>
  158.  
  159.  
  160.  
  161. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  162.  
  163. Block-level
  164.  
  165. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  166.  
  167.  
  168.  
  169. <xsl:attribute-set name="h1">
  170.  
  171. <xsl:attribute name="font-size">2em</xsl:attribute>
  172.  
  173. <xsl:attribute name="font-weight">bold</xsl:attribute>
  174.  
  175. <xsl:attribute name="space-before">0.67em</xsl:attribute>
  176.  
  177. <xsl:attribute name="space-after">0.67em</xsl:attribute>
  178.  
  179. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  180.  
  181. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  182.  
  183. </xsl:attribute-set>
  184.  
  185.  
  186.  
  187. <xsl:attribute-set name="h2">
  188.  
  189. <xsl:attribute name="font-size">1.5em</xsl:attribute>
  190.  
  191. <xsl:attribute name="font-weight">bold</xsl:attribute>
  192.  
  193. <xsl:attribute name="space-before">0.83em</xsl:attribute>
  194.  
  195. <xsl:attribute name="space-after">0.83em</xsl:attribute>
  196.  
  197. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  198.  
  199. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  200.  
  201. </xsl:attribute-set>
  202.  
  203.  
  204.  
  205. <xsl:attribute-set name="h3">
  206.  
  207. <xsl:attribute name="font-size">1.17em</xsl:attribute>
  208.  
  209. <xsl:attribute name="font-weight">bold</xsl:attribute>
  210.  
  211. <xsl:attribute name="space-before">1em</xsl:attribute>
  212.  
  213. <xsl:attribute name="space-after">1em</xsl:attribute>
  214.  
  215. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  216.  
  217. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  218.  
  219. </xsl:attribute-set>
  220.  
  221.  
  222.  
  223. <xsl:attribute-set name="h4">
  224.  
  225. <xsl:attribute name="font-size">1em</xsl:attribute>
  226.  
  227. <xsl:attribute name="font-weight">bold</xsl:attribute>
  228.  
  229. <xsl:attribute name="space-before">1.17em</xsl:attribute>
  230.  
  231. <xsl:attribute name="space-after">1.17em</xsl:attribute>
  232.  
  233. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  234.  
  235. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  236.  
  237. </xsl:attribute-set>
  238.  
  239.  
  240.  
  241. <xsl:attribute-set name="h5">
  242.  
  243. <xsl:attribute name="font-size">0.83em</xsl:attribute>
  244.  
  245. <xsl:attribute name="font-weight">bold</xsl:attribute>
  246.  
  247. <xsl:attribute name="space-before">1.33em</xsl:attribute>
  248.  
  249. <xsl:attribute name="space-after">1.33em</xsl:attribute>
  250.  
  251. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  252.  
  253. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  254.  
  255. </xsl:attribute-set>
  256.  
  257.  
  258.  
  259. <xsl:attribute-set name="h6">
  260.  
  261. <xsl:attribute name="font-size">0.67em</xsl:attribute>
  262.  
  263. <xsl:attribute name="font-weight">bold</xsl:attribute>
  264.  
  265. <xsl:attribute name="space-before">1.67em</xsl:attribute>
  266.  
  267. <xsl:attribute name="space-after">1.67em</xsl:attribute>
  268.  
  269. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  270.  
  271. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  272.  
  273. </xsl:attribute-set>
  274.  
  275.  
  276.  
  277. <xsl:attribute-set name="p">
  278.  
  279. <xsl:attribute name="space-before">1em</xsl:attribute>
  280.  
  281. <xsl:attribute name="space-after">1em</xsl:attribute>
  282. <!-- <xsl:attribute name="font-weight">bold</xsl:attribute>jai added this line-->
  283.  
  284. <!-- e.g.,
  285.  
  286. <xsl:attribute name="text-indent">1em</xsl:attribute>
  287.  
  288. -->
  289.  
  290. </xsl:attribute-set>
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300. <xsl:attribute-set name="p-initial" use-attribute-sets="p">
  301.  
  302. <!-- initial paragraph, preceded by h1..6 or div -->
  303.  
  304. <!-- e.g.,
  305.  
  306. <xsl:attribute name="text-indent">0em</xsl:attribute>
  307.  
  308. -->
  309.  
  310. </xsl:attribute-set>
  311.  
  312.  
  313.  
  314. <xsl:attribute-set name="p-initial-first" use-attribute-sets="p-initial">
  315.  
  316. <!-- initial paragraph, first child of div, body or td -->
  317.  
  318. </xsl:attribute-set>
  319.  
  320.  
  321.  
  322. <xsl:attribute-set name="blockquote">
  323.  
  324. <xsl:attribute name="start-indent">inherited-property-value(start-indent) + 24pt</xsl:attribute>
  325.  
  326. <xsl:attribute name="end-indent">inherited-property-value(end-indent) + 24pt</xsl:attribute>
  327.  
  328. <xsl:attribute name="space-before">1em</xsl:attribute>
  329.  
  330. <xsl:attribute name="space-after">1em</xsl:attribute>
  331.  
  332. </xsl:attribute-set>
  333.  
  334.  
  335.  
  336. <xsl:attribute-set name="pre">
  337.  
  338. <xsl:attribute name="font-size">0.83em</xsl:attribute>
  339.  
  340. <xsl:attribute name="font-family">monospace</xsl:attribute>
  341.  
  342. <xsl:attribute name="white-space">pre</xsl:attribute>
  343.  
  344. <xsl:attribute name="space-before">1em</xsl:attribute>
  345.  
  346. <xsl:attribute name="space-after">1em</xsl:attribute>
  347.  
  348. </xsl:attribute-set>
  349.  
  350.  
  351.  
  352. <xsl:attribute-set name="address">
  353.  
  354. <xsl:attribute name="font-style">italic</xsl:attribute>
  355.  
  356. </xsl:attribute-set>
  357.  
  358.  
  359.  
  360. <xsl:attribute-set name="hr">
  361.  
  362. <xsl:attribute name="border">1px inset</xsl:attribute>
  363.  
  364. <xsl:attribute name="space-before">0.67em</xsl:attribute>
  365.  
  366. <xsl:attribute name="space-after">0.67em</xsl:attribute>
  367.  
  368. </xsl:attribute-set>
  369.  
  370.  
  371.  
  372. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  373.  
  374. List
  375.  
  376. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  377.  
  378.  
  379.  
  380. <xsl:attribute-set name="ul">
  381.  
  382. <xsl:attribute name="space-before">1em</xsl:attribute>
  383.  
  384. <xsl:attribute name="space-after">1em</xsl:attribute>
  385.  
  386. </xsl:attribute-set>
  387.  
  388.  
  389.  
  390. <xsl:attribute-set name="ul-nested">
  391.  
  392. <xsl:attribute name="space-before">0pt</xsl:attribute>
  393.  
  394. <xsl:attribute name="space-after">0pt</xsl:attribute>
  395.  
  396. </xsl:attribute-set>
  397.  
  398.  
  399.  
  400. <xsl:attribute-set name="ol">
  401.  
  402. <xsl:attribute name="space-before">1em</xsl:attribute>
  403.  
  404. <xsl:attribute name="space-after">1em</xsl:attribute>
  405.  
  406. </xsl:attribute-set>
  407.  
  408.  
  409.  
  410. <xsl:attribute-set name="ol-nested">
  411.  
  412. <xsl:attribute name="space-before">0pt</xsl:attribute>
  413.  
  414. <xsl:attribute name="space-after">0pt</xsl:attribute>
  415.  
  416. </xsl:attribute-set>
  417.  
  418.  
  419.  
  420. <xsl:attribute-set name="ul-li">
  421.  
  422. <!-- for (unordered)fo:list-item -->
  423.  
  424. <xsl:attribute name="relative-align">baseline</xsl:attribute>
  425.  
  426. </xsl:attribute-set>
  427.  
  428.  
  429.  
  430. <xsl:attribute-set name="ol-li">
  431.  
  432. <!-- for (ordered)fo:list-item -->
  433.  
  434. <xsl:attribute name="relative-align">baseline</xsl:attribute>
  435.  
  436. </xsl:attribute-set>
  437.  
  438.  
  439.  
  440. <xsl:attribute-set name="dl">
  441.  
  442. <xsl:attribute name="space-before">1em</xsl:attribute>
  443.  
  444. <xsl:attribute name="space-after">1em</xsl:attribute>
  445.  
  446. </xsl:attribute-set>
  447.  
  448.  
  449.  
  450. <xsl:attribute-set name="dt">
  451.  
  452. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  453.  
  454. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  455.  
  456. </xsl:attribute-set>
  457.  
  458.  
  459.  
  460. <xsl:attribute-set name="dd">
  461.  
  462. <xsl:attribute name="start-indent">inherited-property-value(start-indent) + 24pt</xsl:attribute>
  463.  
  464. </xsl:attribute-set>
  465.  
  466.  
  467.  
  468. <!-- list-item-label format for each nesting level -->
  469.  
  470.  
  471.  
  472. <xsl:param name="ul-label-1">&#x2022;</xsl:param>
  473.  
  474. <xsl:attribute-set name="ul-label-1">
  475.  
  476. <xsl:attribute name="font">1em serif</xsl:attribute>
  477.  
  478. </xsl:attribute-set>
  479.  
  480.  
  481.  
  482. <xsl:param name="ul-label-2">o</xsl:param>
  483.  
  484. <xsl:attribute-set name="ul-label-2">
  485.  
  486. <xsl:attribute name="font">0.67em monospace</xsl:attribute>
  487.  
  488. <xsl:attribute name="baseline-shift">0.25em</xsl:attribute>
  489.  
  490. </xsl:attribute-set>
  491.  
  492.  
  493.  
  494. <xsl:param name="ul-label-3">-</xsl:param>
  495.  
  496. <xsl:attribute-set name="ul-label-3">
  497.  
  498. <xsl:attribute name="font">bold 0.9em sans-serif</xsl:attribute>
  499.  
  500. <xsl:attribute name="baseline-shift">0.05em</xsl:attribute>
  501.  
  502. </xsl:attribute-set>
  503.  
  504.  
  505.  
  506. <xsl:param name="ol-label-1">1.</xsl:param>
  507.  
  508. <xsl:attribute-set name="ol-label-1"/>
  509.  
  510.  
  511.  
  512. <xsl:param name="ol-label-2">a.</xsl:param>
  513.  
  514. <xsl:attribute-set name="ol-label-2"/>
  515.  
  516.  
  517.  
  518. <xsl:param name="ol-label-3">i.</xsl:param>
  519.  
  520. <xsl:attribute-set name="ol-label-3"/>
  521.  
  522.  
  523.  
  524. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  525.  
  526. Table
  527.  
  528. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  529.  
  530.  
  531.  
  532. <xsl:attribute-set name="inside-table">
  533.  
  534. <!-- prevent unwanted inheritance -->
  535.  
  536. <xsl:attribute name="start-indent">0pt</xsl:attribute>
  537.  
  538. <xsl:attribute name="end-indent">0pt</xsl:attribute>
  539.  
  540. <xsl:attribute name="text-indent">0pt</xsl:attribute>
  541.  
  542. <xsl:attribute name="last-line-end-indent">0pt</xsl:attribute>
  543.  
  544. <xsl:attribute name="text-align">start</xsl:attribute>
  545.  
  546. <xsl:attribute name="text-align-last">relative</xsl:attribute>
  547.  
  548. </xsl:attribute-set>
  549.  
  550.  
  551.  
  552. <xsl:attribute-set name="table-and-caption" >
  553.  
  554. <!-- horizontal alignment of table itself
  555.  
  556. <xsl:attribute name="text-align">center</xsl:attribute>
  557.  
  558. -->
  559.  
  560. <!-- vertical alignment in table-cell -->
  561.  
  562. <xsl:attribute name="display-align">center</xsl:attribute>
  563.  
  564. </xsl:attribute-set>
  565.  
  566.  
  567.  
  568. <xsl:attribute-set name="table">
  569.  
  570. <xsl:attribute name="border-collapse">separate</xsl:attribute>
  571.  
  572. <xsl:attribute name="border-spacing">2px</xsl:attribute>
  573.  
  574. <xsl:attribute name="border">1px</xsl:attribute>
  575.  
  576.  
  577.  
  578. <xsl:attribute name="border-style">outset</xsl:attribute>
  579.  
  580.  
  581.  
  582. </xsl:attribute-set>
  583.  
  584.  
  585.  
  586. <xsl:attribute-set name="table-caption" use-attribute-sets="inside-table">
  587.  
  588. <xsl:attribute name="text-align">center</xsl:attribute>
  589.  
  590. </xsl:attribute-set>
  591.  
  592.  
  593.  
  594. <xsl:attribute-set name="table-column">
  595.  
  596. </xsl:attribute-set>
  597.  
  598.  
  599.  
  600. <xsl:attribute-set name="thead" use-attribute-sets="inside-table">
  601.  
  602. </xsl:attribute-set>
  603.  
  604.  
  605.  
  606. <xsl:attribute-set name="tfoot" use-attribute-sets="inside-table">
  607.  
  608. </xsl:attribute-set>
  609.  
  610.  
  611.  
  612. <xsl:attribute-set name="tbody" use-attribute-sets="inside-table">
  613.  
  614. </xsl:attribute-set>
  615.  
  616.  
  617.  
  618. <xsl:attribute-set name="tr">
  619.  
  620. </xsl:attribute-set>
  621.  
  622.  
  623.  
  624. <xsl:attribute-set name="th">
  625.  
  626. <xsl:attribute name="font-weight">bolder</xsl:attribute>
  627.  
  628. <xsl:attribute name="text-align">center</xsl:attribute>
  629.  
  630. <xsl:attribute name="border">1px</xsl:attribute>
  631.  
  632. <!--
  633.  
  634. <xsl:attribute name="border-style">inset</xsl:attribute>
  635.  
  636. -->
  637.  
  638. <xsl:attribute name="padding">1px</xsl:attribute>
  639.  
  640. </xsl:attribute-set>
  641.  
  642.  
  643.  
  644. <xsl:attribute-set name="td">
  645.  
  646. <xsl:attribute name="border">1px</xsl:attribute>
  647.  
  648. <!--
  649.  
  650. <xsl:attribute name="border-style">inset</xsl:attribute>
  651.  
  652. -->
  653.  
  654. <xsl:attribute name="padding">1px</xsl:attribute>
  655.  
  656. </xsl:attribute-set>
  657.  
  658.  
  659.  
  660. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  661.  
  662. Inline-level
  663.  
  664. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  665.  
  666.  
  667.  
  668. <xsl:attribute-set name="b">
  669.  
  670. <xsl:attribute name="font-weight">bolder</xsl:attribute>
  671.  
  672. </xsl:attribute-set>
  673.  
  674. <xsl:attribute-set name="strong">
  675.  
  676. <xsl:attribute name="font-weight">bolder</xsl:attribute>
  677.  
  678. </xsl:attribute-set>
  679.  
  680.  
  681.  
  682. <xsl:attribute-set name="strong-em">
  683.  
  684. <xsl:attribute name="font-weight">bolder</xsl:attribute>
  685.  
  686. <xsl:attribute name="font-style">italic</xsl:attribute>
  687.  
  688. </xsl:attribute-set>
  689.  
  690.  
  691.  
  692. <xsl:attribute-set name="i">
  693.  
  694. <xsl:attribute name="font-style">italic</xsl:attribute>
  695.  
  696. </xsl:attribute-set>
  697.  
  698. <xsl:attribute-set name="cite">
  699.  
  700. <xsl:attribute name="font-style">italic</xsl:attribute>
  701.  
  702. </xsl:attribute-set>
  703.  
  704. <xsl:attribute-set name="em">
  705.  
  706. <xsl:attribute name="font-style">italic</xsl:attribute>
  707.  
  708. </xsl:attribute-set>
  709.  
  710. <xsl:attribute-set name="var">
  711.  
  712. <xsl:attribute name="font-style">italic</xsl:attribute>
  713.  
  714. </xsl:attribute-set>
  715.  
  716. <xsl:attribute-set name="dfn">
  717.  
  718. <xsl:attribute name="font-style">italic</xsl:attribute>
  719.  
  720. </xsl:attribute-set>
  721.  
  722.  
  723.  
  724. <xsl:attribute-set name="tt">
  725.  
  726. <xsl:attribute name="font-family">monospace</xsl:attribute>
  727.  
  728. </xsl:attribute-set>
  729.  
  730. <xsl:attribute-set name="code">
  731.  
  732. <xsl:attribute name="font-family">monospace</xsl:attribute>
  733.  
  734. </xsl:attribute-set>
  735.  
  736. <xsl:attribute-set name="kbd">
  737.  
  738. <xsl:attribute name="font-family">monospace</xsl:attribute>
  739.  
  740. </xsl:attribute-set>
  741.  
  742. <xsl:attribute-set name="samp">
  743.  
  744. <xsl:attribute name="font-family">monospace</xsl:attribute>
  745.  
  746. </xsl:attribute-set>
  747.  
  748.  
  749.  
  750. <xsl:attribute-set name="big">
  751.  
  752. <xsl:attribute name="font-size">larger</xsl:attribute>
  753.  
  754. </xsl:attribute-set>
  755.  
  756. <xsl:attribute-set name="small">
  757.  
  758. <xsl:attribute name="font-size">smaller</xsl:attribute>
  759.  
  760. </xsl:attribute-set>
  761.  
  762.  
  763.  
  764. <xsl:attribute-set name="sub">
  765.  
  766. <xsl:attribute name="baseline-shift">sub</xsl:attribute>
  767.  
  768. <xsl:attribute name="font-size">smaller</xsl:attribute>
  769.  
  770. </xsl:attribute-set>
  771.  
  772. <xsl:attribute-set name="sup">
  773.  
  774. <xsl:attribute name="baseline-shift">super</xsl:attribute>
  775.  
  776. <xsl:attribute name="font-size">smaller</xsl:attribute>
  777.  
  778. </xsl:attribute-set>
  779.  
  780.  
  781.  
  782. <xsl:attribute-set name="s">
  783.  
  784. <xsl:attribute name="text-decoration">line-through</xsl:attribute>
  785.  
  786. </xsl:attribute-set>
  787.  
  788. <xsl:attribute-set name="strike">
  789.  
  790. <xsl:attribute name="text-decoration">line-through</xsl:attribute>
  791.  
  792. </xsl:attribute-set>
  793.  
  794. <xsl:attribute-set name="del">
  795.  
  796. <xsl:attribute name="text-decoration">line-through</xsl:attribute>
  797.  
  798. </xsl:attribute-set>
  799.  
  800.  
  801.  
  802. <xsl:attribute-set name="u">
  803.  
  804. <xsl:attribute name="text-decoration">underline</xsl:attribute>
  805.  
  806. </xsl:attribute-set>
  807.  
  808. <xsl:attribute-set name="ins">
  809.  
  810. <xsl:attribute name="text-decoration">underline</xsl:attribute>
  811.  
  812. </xsl:attribute-set>
  813.  
  814.  
  815.  
  816. <xsl:attribute-set name="abbr">
  817.  
  818. <!-- e.g.,
  819.  
  820. <xsl:attribute name="font-variant">small-caps</xsl:attribute>
  821.  
  822. <xsl:attribute name="letter-spacing">0.1em</xsl:attribute>
  823.  
  824. -->
  825.  
  826. </xsl:attribute-set>
  827.  
  828.  
  829.  
  830. <xsl:attribute-set name="acronym">
  831.  
  832. <!-- e.g.,
  833.  
  834. <xsl:attribute name="font-variant">small-caps</xsl:attribute>
  835.  
  836. <xsl:attribute name="letter-spacing">0.1em</xsl:attribute>
  837.  
  838. -->
  839.  
  840. </xsl:attribute-set>
  841.  
  842.  
  843.  
  844. <xsl:attribute-set name="q"/>
  845.  
  846. <xsl:attribute-set name="q-nested"/>
  847.  
  848.  
  849.  
  850. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  851.  
  852. Image
  853.  
  854. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  855.  
  856.  
  857.  
  858. <xsl:attribute-set name="img">
  859.  
  860. </xsl:attribute-set>
  861.  
  862.  
  863.  
  864. <xsl:attribute-set name="img-link">
  865.  
  866. <xsl:attribute name="border">2px solid</xsl:attribute>
  867.  
  868. </xsl:attribute-set>
  869.  
  870.  
  871.  
  872. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  873.  
  874. Link
  875.  
  876. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  877.  
  878.  
  879.  
  880. <xsl:attribute-set name="a-link">
  881.  
  882. <xsl:attribute name="text-decoration">underline</xsl:attribute>
  883.  
  884. <xsl:attribute name="color">blue</xsl:attribute>
  885.  
  886. </xsl:attribute-set>
  887.  
  888.  
  889.  
  890.  
  891.  
  892. <!--======================================================================
  893.  
  894. Templates
  895.  
  896. =======================================================================-->
  897.  
  898.  
  899.  
  900. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  901.  
  902. Root
  903.  
  904. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  905.  
  906.  
  907.  
  908. <xsl:template match="html">
  909.  
  910. <fo:root xsl:use-attribute-sets="root">
  911.  
  912. <xsl:call-template name="process-common-attributes"/>
  913.  
  914. <xsl:call-template name="make-layout-master-set"/>
  915.  
  916. <xsl:apply-templates/>
  917.  
  918. </fo:root>
  919.  
  920. </xsl:template>
  921.  
  922.  
  923.  
  924. <xsl:template name="make-layout-master-set">
  925.  
  926. <fo:layout-master-set>
  927.  
  928. <fo:simple-page-master master-name="all-pages"
  929.  
  930. xsl:use-attribute-sets="page">
  931.  
  932. <fo:region-body margin-top="{$page-margin-top}"
  933.  
  934. margin-right="{$page-margin-right}"
  935.  
  936. margin-bottom="{$page-margin-bottom}"
  937.  
  938. margin-left="{$page-margin-left}"
  939.  
  940. column-count="{$column-count}"
  941.  
  942. column-gap="{$column-gap}"/>
  943.  
  944. <xsl:choose>
  945.  
  946. <xsl:when test="$writing-mode = 'tb-rl'">
  947.  
  948. <fo:region-before extent="{$page-margin-right}"
  949.  
  950. precedence="true"/>
  951.  
  952. <fo:region-after extent="{$page-margin-left}"
  953.  
  954. precedence="true"/>
  955.  
  956. <fo:region-start region-name="page-header"
  957.  
  958. extent="{$page-margin-top}"
  959.  
  960. writing-mode="lr-tb"
  961.  
  962. display-align="before"/>
  963.  
  964. <fo:region-end region-name="page-footer"
  965.  
  966. extent="{$page-margin-bottom}"
  967.  
  968. writing-mode="lr-tb"
  969.  
  970. display-align="after"/>
  971.  
  972. </xsl:when>
  973.  
  974. <xsl:when test="$writing-mode = 'rl-tb'">
  975.  
  976. <fo:region-before region-name="page-header"
  977.  
  978. extent="{$page-margin-top}"
  979.  
  980. display-align="before"/>
  981.  
  982. <fo:region-after region-name="page-footer"
  983.  
  984. extent="{$page-margin-bottom}"
  985.  
  986. display-align="after"/>
  987.  
  988. <fo:region-start extent="{$page-margin-right}"/>
  989.  
  990. <fo:region-end extent="{$page-margin-left}"/>
  991.  
  992. </xsl:when>
  993.  
  994. <xsl:otherwise><!-- $writing-mode = 'lr-tb' -->
  995.  
  996. <fo:region-before region-name="page-header"
  997.  
  998. extent="{$page-margin-top}"
  999.  
  1000. display-align="before"/>
  1001.  
  1002. <fo:region-after region-name="page-footer"
  1003.  
  1004. extent="{$page-margin-bottom}"
  1005.  
  1006. display-align="after"/>
  1007.  
  1008. <fo:region-start extent="{$page-margin-left}"/>
  1009.  
  1010. <fo:region-end extent="{$page-margin-bottom}"/>
  1011.  
  1012. </xsl:otherwise>
  1013.  
  1014. </xsl:choose>
  1015.  
  1016. </fo:simple-page-master>
  1017.  
  1018. </fo:layout-master-set>
  1019.  
  1020. </xsl:template>
  1021.  
  1022.  
  1023.  
  1024. <xsl:template match="head | script"/>
  1025.  
  1026.  
  1027.  
  1028. <xsl:template match="body">
  1029.  
  1030. <fo:page-sequence master-reference="all-pages">
  1031.  
  1032. <fo:title>
  1033.  
  1034. <xsl:value-of select="/html/head/title"/>
  1035.  
  1036. </fo:title>
  1037.  
  1038. <fo:static-content flow-name="page-header">
  1039.  
  1040. <fo:block space-before.conditionality="retain"
  1041.  
  1042. space-before="{$page-header-margin}"
  1043.  
  1044. xsl:use-attribute-sets="page-header">
  1045.  
  1046. <xsl:if test="$title-print-in-header = 'true'">
  1047.  
  1048. <xsl:value-of select="/html/head/title"/>
  1049.  
  1050. </xsl:if>
  1051.  
  1052. </fo:block>
  1053.  
  1054. </fo:static-content>
  1055.  
  1056. <fo:static-content flow-name="page-footer">
  1057.  
  1058. <fo:block space-after.conditionality="retain"
  1059.  
  1060. space-after="{$page-footer-margin}"
  1061.  
  1062. xsl:use-attribute-sets="page-footer">
  1063.  
  1064. <xsl:if test="$page-number-print-in-footer = 'true'">
  1065.  
  1066. <xsl:text>- </xsl:text>
  1067.  
  1068. <fo:page-number/>
  1069.  
  1070. <xsl:text> -</xsl:text>
  1071.  
  1072. </xsl:if>
  1073.  
  1074. </fo:block>
  1075.  
  1076. </fo:static-content>
  1077.  
  1078. <fo:flow flow-name="xsl-region-body">
  1079.  
  1080. <fo:block xsl:use-attribute-sets="body">
  1081.  
  1082. <xsl:call-template name="process-common-attributes"/>
  1083.  
  1084. <xsl:apply-templates/>
  1085.  
  1086. </fo:block>
  1087.  
  1088. </fo:flow>
  1089.  
  1090. </fo:page-sequence>
  1091.  
  1092. </xsl:template>
  1093.  
  1094.  
  1095.  
  1096. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1097.  
  1098. process common attributes and children
  1099.  
  1100. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1101.  
  1102.  
  1103.  
  1104. <xsl:template name="process-common-attributes-and-children">
  1105.  
  1106. <xsl:call-template name="process-common-attributes"/>
  1107.  
  1108. <xsl:apply-templates/>
  1109.  
  1110. </xsl:template>
  1111.  
  1112.  
  1113.  
  1114. <xsl:template name="process-common-attributes">
  1115.  
  1116. <xsl:attribute name="role">
  1117.  
  1118. <xsl:value-of select="concat('', local-name())"/>
  1119.  
  1120. </xsl:attribute>
  1121.  
  1122.  
  1123.  
  1124. <xsl:choose>
  1125.  
  1126. <xsl:when test="@xml:lang">
  1127.  
  1128. <xsl:attribute name="xml:lang">
  1129.  
  1130. <xsl:value-of select="@xml:lang"/>
  1131.  
  1132. </xsl:attribute>
  1133.  
  1134. </xsl:when>
  1135.  
  1136. <xsl:when test="@lang">
  1137.  
  1138. <xsl:attribute name="xml:lang">
  1139.  
  1140. <xsl:value-of select="@lang"/>
  1141.  
  1142. </xsl:attribute>
  1143.  
  1144. </xsl:when>
  1145.  
  1146. </xsl:choose>
  1147.  
  1148.  
  1149.  
  1150. <xsl:choose>
  1151.  
  1152. <xsl:when test="@id">
  1153.  
  1154. <xsl:attribute name="id">
  1155.  
  1156. <xsl:value-of select="@id"/>
  1157.  
  1158. </xsl:attribute>
  1159.  
  1160. </xsl:when>
  1161.  
  1162. <xsl:when test="self::a/@name">
  1163.  
  1164. <xsl:attribute name="id">
  1165.  
  1166. <xsl:value-of select="@name"/>
  1167.  
  1168. </xsl:attribute>
  1169.  
  1170. </xsl:when>
  1171.  
  1172. </xsl:choose>
  1173.  
  1174.  
  1175.  
  1176. <xsl:if test="@align">
  1177.  
  1178. <xsl:choose>
  1179.  
  1180. <xsl:when test="self::caption">
  1181.  
  1182. </xsl:when>
  1183.  
  1184. <xsl:when test="self::img or self::object">
  1185.  
  1186. <xsl:if test="@align = 'bottom' or @align = 'middle' or @align = 'top'">
  1187.  
  1188. <xsl:attribute name="vertical-align">
  1189.  
  1190. <xsl:value-of select="@align"/>
  1191.  
  1192. </xsl:attribute>
  1193.  
  1194. </xsl:if>
  1195.  
  1196. </xsl:when>
  1197.  
  1198. <xsl:otherwise>
  1199.  
  1200. <xsl:call-template name="process-cell-align">
  1201.  
  1202. <xsl:with-param name="align" select="@align"/>
  1203.  
  1204. </xsl:call-template>
  1205.  
  1206. </xsl:otherwise>
  1207.  
  1208. </xsl:choose>
  1209.  
  1210. </xsl:if>
  1211.  
  1212. <xsl:if test="@valign">
  1213.  
  1214. <xsl:call-template name="process-cell-valign">
  1215.  
  1216. <xsl:with-param name="valign" select="@valign"/>
  1217.  
  1218. </xsl:call-template>
  1219.  
  1220. </xsl:if>
  1221.  
  1222.  
  1223.  
  1224. <xsl:if test="@style">
  1225.  
  1226. <xsl:call-template name="process-style">
  1227.  
  1228. <xsl:with-param name="style" select="@style"/>
  1229.  
  1230. </xsl:call-template>
  1231.  
  1232. </xsl:if>
  1233.  
  1234.  
  1235.  
  1236. </xsl:template>
  1237.  
  1238.  
  1239.  
  1240. <xsl:template name="process-style">
  1241.  
  1242. <xsl:param name="style"/>
  1243.  
  1244. <!-- e.g., style="text-align: center; color: red"
  1245.  
  1246. converted to text-align="center" color="red" -->
  1247.  
  1248. <xsl:variable name="name"
  1249.  
  1250. select="normalize-space(substring-before($style, ':'))"/>
  1251.  
  1252. <xsl:if test="$name">
  1253.  
  1254. <xsl:variable name="value-and-rest"
  1255.  
  1256. select="normalize-space(substring-after($style, ':'))"/>
  1257.  
  1258. <xsl:variable name="value">
  1259.  
  1260. <xsl:choose>
  1261.  
  1262. <xsl:when test="contains($value-and-rest, ';')">
  1263.  
  1264. <xsl:value-of select="normalize-space(substring-before(
  1265.  
  1266. $value-and-rest, ';'))"/>
  1267.  
  1268. </xsl:when>
  1269.  
  1270. <xsl:otherwise>
  1271.  
  1272. <xsl:value-of select="$value-and-rest"/>
  1273.  
  1274. </xsl:otherwise>
  1275.  
  1276. </xsl:choose>
  1277.  
  1278. </xsl:variable>
  1279.  
  1280. <xsl:choose>
  1281.  
  1282. <xsl:when test="$name = 'width' and (self::col or self::colgroup)">
  1283.  
  1284. <xsl:attribute name="column-width">
  1285.  
  1286. <xsl:value-of select="$value"/>
  1287.  
  1288. </xsl:attribute>
  1289.  
  1290. </xsl:when>
  1291.  
  1292. <xsl:when test="$name = 'vertical-align' and (
  1293.  
  1294. self::table or self::caption or
  1295.  
  1296. self::thead or self::tfoot or
  1297.  
  1298. self::tbody or self::colgroup or
  1299.  
  1300. self::col or self::tr or
  1301.  
  1302. self::th or self::td)">
  1303.  
  1304. <xsl:choose>
  1305.  
  1306. <xsl:when test="$value = 'top'">
  1307.  
  1308. <xsl:attribute name="display-align">before</xsl:attribute>
  1309.  
  1310. </xsl:when>
  1311.  
  1312. <xsl:when test="$value = 'bottom'">
  1313.  
  1314. <xsl:attribute name="display-align">after</xsl:attribute>
  1315.  
  1316. </xsl:when>
  1317.  
  1318. <xsl:when test="$value = 'middle'">
  1319.  
  1320. <xsl:attribute name="display-align">center</xsl:attribute>
  1321.  
  1322. </xsl:when>
  1323.  
  1324. <xsl:otherwise>
  1325.  
  1326. <xsl:attribute name="display-align">auto</xsl:attribute>
  1327.  
  1328. <xsl:attribute name="relative-align">baseline</xsl:attribute>
  1329.  
  1330. </xsl:otherwise>
  1331.  
  1332. </xsl:choose>
  1333.  
  1334. </xsl:when>
  1335.  
  1336. <xsl:otherwise>
  1337.  
  1338. <xsl:attribute name="{$name}">
  1339.  
  1340. <xsl:value-of select="$value"/>
  1341.  
  1342. </xsl:attribute>
  1343.  
  1344. </xsl:otherwise>
  1345.  
  1346. </xsl:choose>
  1347.  
  1348. </xsl:if>
  1349.  
  1350. <xsl:variable name="rest"
  1351.  
  1352. select="normalize-space(substring-after($style, ';'))"/>
  1353.  
  1354. <xsl:if test="$rest">
  1355.  
  1356. <xsl:call-template name="process-style">
  1357.  
  1358. <xsl:with-param name="style" select="$rest"/>
  1359.  
  1360. </xsl:call-template>
  1361.  
  1362. </xsl:if>
  1363.  
  1364. </xsl:template>
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1371.  
  1372. Block-level
  1373.  
  1374. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1375.  
  1376.  
  1377.  
  1378. <xsl:template match="h1">
  1379.  
  1380. <fo:block xsl:use-attribute-sets="h1">
  1381.  
  1382. <xsl:call-template name="process-common-attributes-and-children"/>
  1383.  
  1384. </fo:block>
  1385.  
  1386. </xsl:template>
  1387.  
  1388.  
  1389.  
  1390. <xsl:template match="h2">
  1391.  
  1392. <fo:block xsl:use-attribute-sets="h2">
  1393.  
  1394. <xsl:call-template name="process-common-attributes-and-children"/>
  1395.  
  1396. </fo:block>
  1397.  
  1398. </xsl:template>
  1399.  
  1400.  
  1401.  
  1402. <xsl:template match="h3">
  1403.  
  1404. <fo:block xsl:use-attribute-sets="h3">
  1405.  
  1406. <xsl:call-template name="process-common-attributes-and-children"/>
  1407.  
  1408. </fo:block>
  1409.  
  1410. </xsl:template>
  1411.  
  1412.  
  1413.  
  1414. <xsl:template match="h4">
  1415.  
  1416. <fo:block xsl:use-attribute-sets="h4">
  1417.  
  1418. <xsl:call-template name="process-common-attributes-and-children"/>
  1419.  
  1420. </fo:block>
  1421.  
  1422. </xsl:template>
  1423.  
  1424.  
  1425.  
  1426. <xsl:template match="h5">
  1427.  
  1428. <fo:block xsl:use-attribute-sets="h5">
  1429.  
  1430. <xsl:call-template name="process-common-attributes-and-children"/>
  1431.  
  1432. </fo:block>
  1433.  
  1434. </xsl:template>
  1435.  
  1436.  
  1437.  
  1438. <xsl:template match="h6">
  1439.  
  1440. <fo:block xsl:use-attribute-sets="h6">
  1441.  
  1442. <xsl:call-template name="process-common-attributes-and-children"/>
  1443.  
  1444. </fo:block>
  1445.  
  1446. </xsl:template>
  1447.  
  1448.  
  1449.  
  1450. <xsl:template match="p">
  1451.  
  1452. <fo:block xsl:use-attribute-sets="p">
  1453.  
  1454. <xsl:call-template name="process-common-attributes-and-children"/>
  1455.  
  1456. </fo:block>
  1457.  
  1458. <!--<fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" break-after="page"/>-->
  1459.  
  1460. </xsl:template>
  1461.  
  1462.  
  1463.  
  1464. <!-- initial paragraph, preceded by h1..6 or div -->
  1465.  
  1466. <xsl:template match="p[preceding-sibling::*[1][
  1467.  
  1468. self::h1 or self::h2 or self::h3 or
  1469.  
  1470. self::h4 or self::h5 or self::h6 or
  1471.  
  1472. self::div]]">
  1473.  
  1474. <fo:block xsl:use-attribute-sets="p-initial">
  1475.  
  1476. <xsl:call-template name="process-common-attributes-and-children"/>
  1477.  
  1478. </fo:block>
  1479.  
  1480. </xsl:template>
  1481.  
  1482.  
  1483.  
  1484. <!-- initial paragraph, first child of div, body or td -->
  1485.  
  1486. <xsl:template match="p[not(preceding-sibling::*) and (
  1487.  
  1488. parent::div or parent::body or
  1489.  
  1490. parent::td)]">
  1491.  
  1492. <fo:block xsl:use-attribute-sets="p-initial-first">
  1493.  
  1494. <xsl:call-template name="process-common-attributes-and-children"/>
  1495.  
  1496. </fo:block>
  1497.  
  1498. </xsl:template>
  1499.  
  1500.  
  1501.  
  1502. <xsl:template match="blockquote">
  1503.  
  1504. <fo:block xsl:use-attribute-sets="blockquote">
  1505.  
  1506. <xsl:call-template name="process-common-attributes-and-children"/>
  1507.  
  1508. </fo:block>
  1509.  
  1510. </xsl:template>
  1511.  
  1512.  
  1513.  
  1514. <xsl:template match="pre">
  1515.  
  1516. <fo:block xsl:use-attribute-sets="pre">
  1517.  
  1518. <xsl:call-template name="process-pre"/>
  1519.  
  1520. </fo:block>
  1521.  
  1522. </xsl:template>
  1523.  
  1524.  
  1525.  
  1526. <xsl:template name="process-pre">
  1527.  
  1528. <xsl:call-template name="process-common-attributes"/>
  1529.  
  1530. <!-- remove leading CR/LF/CRLF char -->
  1531.  
  1532. <xsl:variable name="crlf"><xsl:text>&#xD;&#xA;</xsl:text></xsl:variable>
  1533.  
  1534. <xsl:variable name="lf"><xsl:text>&#xA;</xsl:text></xsl:variable>
  1535.  
  1536. <xsl:variable name="cr"><xsl:text>&#xD;</xsl:text></xsl:variable>
  1537.  
  1538. <xsl:for-each select="node()">
  1539.  
  1540. <xsl:choose>
  1541.  
  1542. <xsl:when test="position() = 1 and self::text()">
  1543.  
  1544. <xsl:choose>
  1545.  
  1546. <xsl:when test="starts-with(., $lf)">
  1547.  
  1548. <xsl:value-of select="substring(., 2)"/>
  1549.  
  1550. </xsl:when>
  1551.  
  1552. <xsl:when test="starts-with(., $crlf)">
  1553.  
  1554. <xsl:value-of select="substring(., 3)"/>
  1555.  
  1556. </xsl:when>
  1557.  
  1558. <xsl:when test="starts-with(., $cr)">
  1559.  
  1560. <xsl:value-of select="substring(., 2)"/>
  1561.  
  1562. </xsl:when>
  1563.  
  1564. <xsl:otherwise>
  1565.  
  1566. <xsl:apply-templates select="."/>
  1567.  
  1568. </xsl:otherwise>
  1569.  
  1570. </xsl:choose>
  1571.  
  1572. </xsl:when>
  1573.  
  1574. <xsl:otherwise>
  1575.  
  1576. <xsl:apply-templates select="."/>
  1577.  
  1578. </xsl:otherwise>
  1579.  
  1580. </xsl:choose>
  1581.  
  1582. </xsl:for-each>
  1583.  
  1584. </xsl:template>
  1585.  
  1586.  
  1587.  
  1588. <xsl:template match="address">
  1589.  
  1590. <fo:block xsl:use-attribute-sets="address">
  1591.  
  1592. <xsl:call-template name="process-common-attributes-and-children"/>
  1593.  
  1594. </fo:block>
  1595.  
  1596. </xsl:template>
  1597.  
  1598.  
  1599.  
  1600. <xsl:template match="hr">
  1601.  
  1602. <fo:block xsl:use-attribute-sets="hr">
  1603.  
  1604. <xsl:call-template name="process-common-attributes"/>
  1605.  
  1606. </fo:block>
  1607.  
  1608. </xsl:template>
  1609.  
  1610.  
  1611.  
  1612. <xsl:template match="div">
  1613.  
  1614. <!-- need fo:block-container? or normal fo:block -->
  1615.  
  1616. <xsl:variable name="need-block-container">
  1617.  
  1618. <xsl:call-template name="need-block-container"/>
  1619.  
  1620. </xsl:variable>
  1621.  
  1622. <xsl:choose>
  1623.  
  1624. <xsl:when test="$need-block-container = 'true'">
  1625.  
  1626. <fo:block-container>
  1627.  
  1628. <xsl:if test="@dir">
  1629.  
  1630. <xsl:attribute name="writing-mode">
  1631.  
  1632. <xsl:choose>
  1633.  
  1634. <xsl:when test="@dir = 'rtl'">rl-tb</xsl:when>
  1635.  
  1636. <xsl:otherwise>lr-tb</xsl:otherwise>
  1637.  
  1638. </xsl:choose>
  1639.  
  1640. </xsl:attribute>
  1641.  
  1642. </xsl:if>
  1643.  
  1644. <xsl:call-template name="process-common-attributes"/>
  1645.  
  1646. <fo:block start-indent="0pt" end-indent="0pt">
  1647.  
  1648. <xsl:apply-templates/>
  1649.  
  1650. </fo:block>
  1651.  
  1652. </fo:block-container>
  1653.  
  1654. </xsl:when>
  1655.  
  1656. <xsl:otherwise>
  1657.  
  1658. <!-- normal block -->
  1659.  
  1660. <fo:block>
  1661.  
  1662. <xsl:call-template name="process-common-attributes"/>
  1663.  
  1664. <xsl:apply-templates/>
  1665.  
  1666. </fo:block>
  1667.  
  1668. </xsl:otherwise>
  1669.  
  1670. </xsl:choose>
  1671.  
  1672. </xsl:template>
  1673.  
  1674.  
  1675.  
  1676. <xsl:template name="need-block-container">
  1677.  
  1678. <xsl:choose>
  1679.  
  1680. <xsl:when test="@dir">true</xsl:when>
  1681.  
  1682. <xsl:when test="@style">
  1683.  
  1684. <xsl:variable name="s"
  1685.  
  1686. select="concat(';', translate(normalize-space(@style),
  1687.  
  1688. ' ', ''))"/>
  1689.  
  1690. <xsl:choose>
  1691.  
  1692. <xsl:when test="contains($s, ';width:') or
  1693.  
  1694. contains($s, ';height:') or
  1695.  
  1696. contains($s, ';position:absolute') or
  1697.  
  1698. contains($s, ';position:fixed') or
  1699.  
  1700. contains($s, ';writing-mode:')">true</xsl:when>
  1701.  
  1702. <xsl:otherwise>false</xsl:otherwise>
  1703.  
  1704. </xsl:choose>
  1705.  
  1706. </xsl:when>
  1707.  
  1708. <xsl:otherwise>false</xsl:otherwise>
  1709.  
  1710. </xsl:choose>
  1711.  
  1712. </xsl:template>
  1713.  
  1714.  
  1715.  
  1716. <xsl:template match="center">
  1717.  
  1718. <fo:block text-align="center">
  1719.  
  1720. <xsl:call-template name="process-common-attributes-and-children"/>
  1721.  
  1722. </fo:block>
  1723.  
  1724. </xsl:template>
  1725.  
  1726.  
  1727.  
  1728. <xsl:template match="fieldset | form | dir | menu">
  1729.  
  1730. <fo:block space-before="1em" space-after="1em">
  1731.  
  1732. <xsl:call-template name="process-common-attributes-and-children"/>
  1733.  
  1734. </fo:block>
  1735.  
  1736. </xsl:template>
  1737.  
  1738.  
  1739.  
  1740. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1741.  
  1742. List
  1743.  
  1744. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1745.  
  1746.  
  1747.  
  1748. <xsl:template match="ul">
  1749.  
  1750. <fo:list-block xsl:use-attribute-sets="ul">
  1751.  
  1752. <xsl:call-template name="process-common-attributes-and-children"/>
  1753.  
  1754. </fo:list-block>
  1755.  
  1756. </xsl:template>
  1757.  
  1758.  
  1759.  
  1760. <xsl:template match="li//ul">
  1761.  
  1762. <fo:list-block xsl:use-attribute-sets="ul-nested">
  1763.  
  1764. <xsl:call-template name="process-common-attributes-and-children"/>
  1765.  
  1766. </fo:list-block>
  1767.  
  1768. </xsl:template>
  1769.  
  1770.  
  1771.  
  1772. <xsl:template match="ol">
  1773.  
  1774. <fo:list-block xsl:use-attribute-sets="ol">
  1775.  
  1776. <xsl:call-template name="process-common-attributes-and-children"/>
  1777.  
  1778. </fo:list-block>
  1779.  
  1780. </xsl:template>
  1781.  
  1782.  
  1783.  
  1784. <xsl:template match="li//ol">
  1785.  
  1786. <fo:list-block xsl:use-attribute-sets="ol-nested">
  1787.  
  1788. <xsl:call-template name="process-common-attributes-and-children"/>
  1789.  
  1790. </fo:list-block>
  1791.  
  1792. </xsl:template>
  1793.  
  1794.  
  1795.  
  1796. <xsl:template match="ul/li">
  1797.  
  1798. <fo:list-item xsl:use-attribute-sets="ul-li">
  1799.  
  1800. <xsl:call-template name="process-ul-li"/>
  1801.  
  1802. </fo:list-item>
  1803.  
  1804. </xsl:template>
  1805.  
  1806.  
  1807.  
  1808. <xsl:template name="process-ul-li">
  1809.  
  1810. <xsl:call-template name="process-common-attributes"/>
  1811.  
  1812. <fo:list-item-label end-indent="label-end()"
  1813.  
  1814. text-align="end" wrap-option="no-wrap">
  1815.  
  1816. <fo:block>
  1817.  
  1818. <xsl:variable name="depth" select="count(ancestor::ul)" />
  1819.  
  1820. <xsl:choose>
  1821.  
  1822. <xsl:when test="$depth = 1">
  1823.  
  1824. <fo:inline xsl:use-attribute-sets="ul-label-1">
  1825.  
  1826. <xsl:value-of select="$ul-label-1"/>
  1827.  
  1828. </fo:inline>
  1829.  
  1830. </xsl:when>
  1831.  
  1832. <xsl:when test="$depth = 2">
  1833.  
  1834. <fo:inline xsl:use-attribute-sets="ul-label-2">
  1835.  
  1836. <xsl:value-of select="$ul-label-2"/>
  1837.  
  1838. </fo:inline>
  1839.  
  1840. </xsl:when>
  1841.  
  1842. <xsl:otherwise>
  1843.  
  1844. <fo:inline xsl:use-attribute-sets="ul-label-3">
  1845.  
  1846. <xsl:value-of select="$ul-label-3"/>
  1847.  
  1848. </fo:inline>
  1849.  
  1850. </xsl:otherwise>
  1851.  
  1852. </xsl:choose>
  1853.  
  1854. </fo:block>
  1855.  
  1856. </fo:list-item-label>
  1857.  
  1858. <fo:list-item-body start-indent="body-start()">
  1859.  
  1860. <fo:block>
  1861.  
  1862. <xsl:apply-templates/>
  1863.  
  1864. </fo:block>
  1865.  
  1866. </fo:list-item-body>
  1867.  
  1868. </xsl:template>
  1869.  
  1870.  
  1871.  
  1872. <xsl:template match="ol/li">
  1873.  
  1874. <fo:list-item xsl:use-attribute-sets="ol-li">
  1875.  
  1876. <xsl:call-template name="process-ol-li"/>
  1877.  
  1878. </fo:list-item>
  1879.  
  1880. </xsl:template>
  1881.  
  1882.  
  1883.  
  1884. <xsl:template name="process-ol-li">
  1885.  
  1886. <xsl:call-template name="process-common-attributes"/>
  1887.  
  1888. <fo:list-item-label end-indent="label-end()"
  1889.  
  1890. text-align="end" wrap-option="no-wrap">
  1891.  
  1892. <fo:block>
  1893.  
  1894. <xsl:variable name="depth" select="count(ancestor::ol)" />
  1895.  
  1896. <xsl:choose>
  1897.  
  1898. <xsl:when test="$depth = 1">
  1899.  
  1900. <fo:inline xsl:use-attribute-sets="ol-label-1">
  1901.  
  1902. <xsl:number format="{$ol-label-1}"/>
  1903.  
  1904. </fo:inline>
  1905.  
  1906. </xsl:when>
  1907.  
  1908. <xsl:when test="$depth = 2">
  1909.  
  1910. <fo:inline xsl:use-attribute-sets="ol-label-2">
  1911.  
  1912. <xsl:number format="{$ol-label-2}"/>
  1913.  
  1914. </fo:inline>
  1915.  
  1916. </xsl:when>
  1917.  
  1918. <xsl:otherwise>
  1919.  
  1920. <fo:inline xsl:use-attribute-sets="ol-label-3">
  1921.  
  1922. <xsl:number format="{$ol-label-3}"/>
  1923.  
  1924. </fo:inline>
  1925.  
  1926. </xsl:otherwise>
  1927.  
  1928. </xsl:choose>
  1929.  
  1930. </fo:block>
  1931.  
  1932. </fo:list-item-label>
  1933.  
  1934. <fo:list-item-body start-indent="body-start()">
  1935.  
  1936. <fo:block>
  1937.  
  1938. <xsl:apply-templates/>
  1939.  
  1940. </fo:block>
  1941.  
  1942. </fo:list-item-body>
  1943.  
  1944. </xsl:template>
  1945.  
  1946.  
  1947.  
  1948. <xsl:template match="dl">
  1949.  
  1950. <fo:block xsl:use-attribute-sets="dl">
  1951.  
  1952. <xsl:call-template name="process-common-attributes-and-children"/>
  1953.  
  1954. </fo:block>
  1955.  
  1956. </xsl:template>
  1957.  
  1958.  
  1959.  
  1960. <xsl:template match="dt">
  1961.  
  1962. <fo:block xsl:use-attribute-sets="dt">
  1963.  
  1964. <xsl:call-template name="process-common-attributes-and-children"/>
  1965.  
  1966. </fo:block>
  1967.  
  1968. </xsl:template>
  1969.  
  1970.  
  1971.  
  1972. <xsl:template match="dd">
  1973.  
  1974. <fo:block xsl:use-attribute-sets="dd">
  1975.  
  1976. <xsl:call-template name="process-common-attributes-and-children"/>
  1977.  
  1978. </fo:block>
  1979.  
  1980. <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format" break-after="page"/>
  1981.  
  1982. </xsl:template>
  1983.  
  1984.  
  1985.  
  1986. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1987.  
  1988. Table
  1989.  
  1990. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1991.  
  1992.  
  1993.  
  1994. <xsl:template match="table">
  1995.  
  1996. <fo:table-and-caption xsl:use-attribute-sets="table-and-caption">
  1997.  
  1998. <xsl:call-template name="make-table-caption"/>
  1999.  
  2000. <fo:table xsl:use-attribute-sets="table">
  2001.  
  2002. <xsl:call-template name="process-table"/>
  2003.  
  2004. </fo:table>
  2005.  
  2006. </fo:table-and-caption>
  2007.  
  2008. </xsl:template>
  2009.  
  2010.  
  2011.  
  2012. <xsl:template name="make-table-caption">
  2013.  
  2014. <xsl:if test="caption/@align">
  2015.  
  2016. <xsl:attribute name="caption-side">
  2017.  
  2018. <xsl:value-of select="caption/@align"/>
  2019.  
  2020. </xsl:attribute>
  2021.  
  2022. </xsl:if>
  2023.  
  2024. <xsl:apply-templates select="caption"/>
  2025.  
  2026. </xsl:template>
  2027.  
  2028.  
  2029.  
  2030. <xsl:template name="process-table">
  2031.  
  2032. <xsl:if test="@width">
  2033.  
  2034. <xsl:attribute name="inline-progression-dimension">
  2035.  
  2036. <xsl:choose>
  2037.  
  2038. <xsl:when test="contains(@width, '%')">
  2039.  
  2040. <xsl:value-of select="@width"/>
  2041.  
  2042. </xsl:when>
  2043.  
  2044. <xsl:otherwise>
  2045.  
  2046. <xsl:value-of select="@width"/>px</xsl:otherwise>
  2047.  
  2048. </xsl:choose>
  2049.  
  2050. </xsl:attribute>
  2051.  
  2052. </xsl:if>
  2053.  
  2054. <xsl:if test="@border or @frame">
  2055.  
  2056. <xsl:choose>
  2057.  
  2058. <xsl:when test="@border &gt; 0">
  2059.  
  2060. <xsl:attribute name="border">
  2061.  
  2062. <xsl:value-of select="@border"/>px</xsl:attribute>
  2063.  
  2064. </xsl:when>
  2065.  
  2066. </xsl:choose>
  2067.  
  2068. <xsl:choose>
  2069.  
  2070. <xsl:when test="@border = '0' or @frame = 'void'">
  2071.  
  2072. <xsl:attribute name="border-style">hidden</xsl:attribute>
  2073.  
  2074. </xsl:when>
  2075.  
  2076. <xsl:when test="@frame = 'above'">
  2077.  
  2078. <xsl:attribute name="border-style">outset hidden hidden hidden</xsl:attribute>
  2079.  
  2080. </xsl:when>
  2081.  
  2082. <xsl:when test="@frame = 'below'">
  2083.  
  2084. <xsl:attribute name="border-style">hidden hidden outset hidden</xsl:attribute>
  2085.  
  2086. </xsl:when>
  2087.  
  2088. <xsl:when test="@frame = 'hsides'">
  2089.  
  2090. <xsl:attribute name="border-style">outset hidden</xsl:attribute>
  2091.  
  2092. </xsl:when>
  2093.  
  2094. <xsl:when test="@frame = 'vsides'">
  2095.  
  2096. <xsl:attribute name="border-style">hidden outset</xsl:attribute>
  2097.  
  2098. </xsl:when>
  2099.  
  2100. <xsl:when test="@frame = 'lhs'">
  2101.  
  2102. <xsl:attribute name="border-style">hidden hidden hidden outset</xsl:attribute>
  2103.  
  2104. </xsl:when>
  2105.  
  2106. <xsl:when test="@frame = 'rhs'">
  2107.  
  2108. <xsl:attribute name="border-style">hidden outset hidden hidden</xsl:attribute>
  2109.  
  2110. </xsl:when>
  2111.  
  2112. <xsl:otherwise>
  2113.  
  2114. <xsl:attribute name="border-style">outset</xsl:attribute>
  2115.  
  2116. </xsl:otherwise>
  2117.  
  2118. </xsl:choose>
  2119.  
  2120. </xsl:if>
  2121.  
  2122. <xsl:if test="@cellspacing">
  2123.  
  2124. <xsl:attribute name="border-spacing">
  2125.  
  2126. <xsl:value-of select="@cellspacing"/>px</xsl:attribute>
  2127.  
  2128. <xsl:attribute name="border-collapse">separate</xsl:attribute>
  2129.  
  2130. </xsl:if>
  2131.  
  2132. <xsl:if test="@rules and (@rules = 'groups' or
  2133.  
  2134. @rules = 'rows' or
  2135.  
  2136. @rules = 'cols' or
  2137.  
  2138. @rules = 'all' and (not(@border or @frame) or
  2139.  
  2140. @border = '0' or @frame and
  2141.  
  2142. not(@frame = 'box' or @frame = 'border')))">
  2143.  
  2144. <xsl:attribute name="border-collapse">collapse</xsl:attribute>
  2145.  
  2146. <xsl:if test="not(@border or @frame)">
  2147.  
  2148. <xsl:attribute name="border-style">hidden</xsl:attribute>
  2149.  
  2150. </xsl:if>
  2151.  
  2152. </xsl:if>
  2153.  
  2154. <xsl:call-template name="process-common-attributes"/>
  2155.  
  2156. <xsl:apply-templates select="col | colgroup"/>
  2157.  
  2158. <xsl:apply-templates select="thead"/>
  2159.  
  2160. <xsl:apply-templates select="tfoot"/>
  2161.  
  2162. <xsl:choose>
  2163.  
  2164. <xsl:when test="tbody">
  2165.  
  2166. <xsl:apply-templates select="tbody"/>
  2167.  
  2168. </xsl:when>
  2169.  
  2170. <xsl:otherwise>
  2171.  
  2172. <fo:table-body xsl:use-attribute-sets="tbody">
  2173.  
  2174. <xsl:apply-templates select="tr"/>
  2175.  
  2176. </fo:table-body>
  2177.  
  2178. </xsl:otherwise>
  2179.  
  2180. </xsl:choose>
  2181.  
  2182. </xsl:template>
  2183.  
  2184.  
  2185.  
  2186. <xsl:template match="caption">
  2187.  
  2188. <fo:table-caption xsl:use-attribute-sets="table-caption">
  2189.  
  2190. <xsl:call-template name="process-common-attributes"/>
  2191.  
  2192. <fo:block>
  2193.  
  2194. <xsl:apply-templates/>
  2195.  
  2196. </fo:block>
  2197.  
  2198. </fo:table-caption>
  2199.  
  2200. </xsl:template>
  2201.  
  2202.  
  2203.  
  2204. <xsl:template match="thead">
  2205.  
  2206. <fo:table-header xsl:use-attribute-sets="thead">
  2207.  
  2208. <xsl:call-template name="process-table-rowgroup"/>
  2209.  
  2210. </fo:table-header>
  2211.  
  2212. </xsl:template>
  2213.  
  2214.  
  2215.  
  2216. <xsl:template match="tfoot">
  2217.  
  2218. <fo:table-footer xsl:use-attribute-sets="tfoot">
  2219.  
  2220. <xsl:call-template name="process-table-rowgroup"/>
  2221.  
  2222. </fo:table-footer>
  2223.  
  2224. </xsl:template>
  2225.  
  2226.  
  2227.  
  2228. <xsl:template match="tbody">
  2229.  
  2230. <fo:table-body xsl:use-attribute-sets="tbody">
  2231.  
  2232. <xsl:call-template name="process-table-rowgroup"/>
  2233.  
  2234. </fo:table-body>
  2235.  
  2236. </xsl:template>
  2237.  
  2238.  
  2239.  
  2240. <xsl:template name="process-table-rowgroup">
  2241.  
  2242. <xsl:if test="ancestor::table[1]/@rules = 'groups'">
  2243.  
  2244. <xsl:attribute name="border">1px solid</xsl:attribute>
  2245.  
  2246. </xsl:if>
  2247.  
  2248. <xsl:call-template name="process-common-attributes-and-children"/>
  2249.  
  2250. </xsl:template>
  2251.  
  2252.  
  2253.  
  2254. <xsl:template match="colgroup">
  2255.  
  2256. <fo:table-column xsl:use-attribute-sets="table-column">
  2257.  
  2258. <xsl:call-template name="process-table-column"/>
  2259.  
  2260. </fo:table-column>
  2261.  
  2262. </xsl:template>
  2263.  
  2264.  
  2265.  
  2266. <xsl:template match="colgroup[col]">
  2267.  
  2268. <xsl:apply-templates/>
  2269.  
  2270. </xsl:template>
  2271.  
  2272.  
  2273.  
  2274. <xsl:template match="col">
  2275.  
  2276. <fo:table-column xsl:use-attribute-sets="table-column">
  2277.  
  2278. <xsl:call-template name="process-table-column"/>
  2279.  
  2280. </fo:table-column>
  2281.  
  2282. </xsl:template>
  2283.  
  2284.  
  2285.  
  2286. <xsl:template name="process-table-column">
  2287.  
  2288. <xsl:if test="parent::colgroup">
  2289.  
  2290. <xsl:call-template name="process-col-width">
  2291.  
  2292. <xsl:with-param name="width" select="../@width"/>
  2293.  
  2294. </xsl:call-template>
  2295.  
  2296. <xsl:call-template name="process-cell-align">
  2297.  
  2298. <xsl:with-param name="align" select="../@align"/>
  2299.  
  2300. </xsl:call-template>
  2301.  
  2302. <xsl:call-template name="process-cell-valign">
  2303.  
  2304. <xsl:with-param name="valign" select="../@valign"/>
  2305.  
  2306. </xsl:call-template>
  2307.  
  2308. </xsl:if>
  2309.  
  2310. <xsl:if test="@span">
  2311.  
  2312. <xsl:attribute name="number-columns-repeated">
  2313.  
  2314. <xsl:value-of select="@span"/>
  2315.  
  2316. </xsl:attribute>
  2317.  
  2318. </xsl:if>
  2319.  
  2320. <xsl:call-template name="process-col-width">
  2321.  
  2322. <xsl:with-param name="width" select="@width"/>
  2323.  
  2324. <!-- it may override parent colgroup's width -->
  2325.  
  2326. </xsl:call-template>
  2327.  
  2328. <xsl:if test="ancestor::table[1]/@rules = 'cols'">
  2329.  
  2330. <xsl:attribute name="border">1px solid</xsl:attribute>
  2331.  
  2332. </xsl:if>
  2333.  
  2334. <xsl:call-template name="process-common-attributes"/>
  2335.  
  2336. <!-- this processes also align and valign -->
  2337.  
  2338. </xsl:template>
  2339.  
  2340.  
  2341.  
  2342. <xsl:template match="tr">
  2343.  
  2344. <fo:table-row xsl:use-attribute-sets="tr">
  2345.  
  2346. <xsl:call-template name="process-table-row"/>
  2347.  
  2348. </fo:table-row>
  2349.  
  2350. </xsl:template>
  2351.  
  2352.  
  2353.  
  2354. <xsl:template match="tr[parent::table and th and not(td)]">
  2355.  
  2356. <fo:table-row xsl:use-attribute-sets="tr" keep-with-next="always">
  2357.  
  2358. <xsl:call-template name="process-table-row"/>
  2359.  
  2360. </fo:table-row>
  2361.  
  2362. </xsl:template>
  2363.  
  2364.  
  2365.  
  2366. <xsl:template name="process-table-row">
  2367.  
  2368. <xsl:if test="ancestor::table[1]/@rules = 'rows'">
  2369.  
  2370. <xsl:attribute name="border">1px solid</xsl:attribute>
  2371.  
  2372. </xsl:if>
  2373.  
  2374. <xsl:call-template name="process-common-attributes-and-children"/>
  2375.  
  2376. </xsl:template>
  2377.  
  2378.  
  2379.  
  2380. <xsl:template match="th">
  2381.  
  2382. <fo:table-cell xsl:use-attribute-sets="th">
  2383.  
  2384. <xsl:call-template name="process-table-cell"/>
  2385.  
  2386. </fo:table-cell>
  2387.  
  2388. </xsl:template>
  2389.  
  2390.  
  2391.  
  2392. <xsl:template match="td">
  2393.  
  2394. <fo:table-cell xsl:use-attribute-sets="td">
  2395.  
  2396. <xsl:call-template name="process-table-cell"/>
  2397.  
  2398. </fo:table-cell>
  2399.  
  2400. </xsl:template>
  2401.  
  2402.  
  2403.  
  2404. <xsl:template name="process-table-cell">
  2405.  
  2406. <xsl:if test="@colspan">
  2407.  
  2408. <xsl:attribute name="number-columns-spanned">
  2409.  
  2410. <xsl:value-of select="@colspan"/>
  2411.  
  2412. </xsl:attribute>
  2413.  
  2414. </xsl:if>
  2415.  
  2416. <xsl:if test="@rowspan">
  2417.  
  2418. <xsl:attribute name="number-rows-spanned">
  2419.  
  2420. <xsl:value-of select="@rowspan"/>
  2421.  
  2422. </xsl:attribute>
  2423.  
  2424. </xsl:if>
  2425.  
  2426. <xsl:for-each select="ancestor::table[1]">
  2427.  
  2428. <xsl:if test="(@border or @rules) and (@rules = 'all' or
  2429.  
  2430. not(@rules) and not(@border = '0'))">
  2431.  
  2432. <xsl:attribute name="border-style">inset</xsl:attribute>
  2433.  
  2434. </xsl:if>
  2435.  
  2436. <xsl:if test="@cellpadding">
  2437.  
  2438. <xsl:attribute name="padding">
  2439.  
  2440. <xsl:choose>
  2441.  
  2442. <xsl:when test="contains(@cellpadding, '%')">
  2443.  
  2444. <xsl:value-of select="@cellpadding"/>
  2445.  
  2446. </xsl:when>
  2447.  
  2448. <xsl:otherwise>
  2449.  
  2450. <xsl:value-of select="@cellpadding"/>px</xsl:otherwise>
  2451.  
  2452. </xsl:choose>
  2453.  
  2454. </xsl:attribute>
  2455.  
  2456. </xsl:if>
  2457.  
  2458. </xsl:for-each>
  2459.  
  2460. <xsl:if test="not(@align or ../@align or
  2461.  
  2462. ../parent::*[self::thead or self::tfoot or
  2463.  
  2464. self::tbody]/@align) and
  2465.  
  2466. ancestor::table[1]/*[self::col or
  2467.  
  2468. self::colgroup]/descendant-or-self::*/@align">
  2469.  
  2470. <xsl:attribute name="text-align">from-table-column()</xsl:attribute>
  2471.  
  2472. </xsl:if>
  2473.  
  2474. <xsl:if test="not(@valign or ../@valign or
  2475.  
  2476. ../parent::*[self::thead or self::tfoot or
  2477.  
  2478. self::tbody]/@valign) and
  2479.  
  2480. ancestor::table[1]/*[self::col or
  2481.  
  2482. self::colgroup]/descendant-or-self::*/@valign">
  2483.  
  2484. <xsl:attribute name="display-align">from-table-column()</xsl:attribute>
  2485.  
  2486. <xsl:attribute name="relative-align">from-table-column()</xsl:attribute>
  2487.  
  2488. </xsl:if>
  2489.  
  2490. <xsl:call-template name="process-common-attributes"/>
  2491.  
  2492. <fo:block>
  2493.  
  2494. <xsl:apply-templates/>
  2495.  
  2496. </fo:block>
  2497.  
  2498. </xsl:template>
  2499.  
  2500.  
  2501.  
  2502. <xsl:template name="process-col-width">
  2503.  
  2504. <xsl:param name="width"/>
  2505.  
  2506. <xsl:if test="$width and $width != '0*'">
  2507.  
  2508. <xsl:attribute name="column-width">
  2509.  
  2510. <xsl:choose>
  2511.  
  2512. <xsl:when test="contains($width, '*')">
  2513.  
  2514. <xsl:text>proportional-column-width(</xsl:text>
  2515.  
  2516. <xsl:value-of select="substring-before($width, '*')"/>
  2517.  
  2518. <xsl:text>)</xsl:text>
  2519.  
  2520. </xsl:when>
  2521.  
  2522. <xsl:when test="contains($width, '%')">
  2523.  
  2524. <xsl:value-of select="$width"/>
  2525.  
  2526. </xsl:when>
  2527.  
  2528. <xsl:otherwise>
  2529.  
  2530. <xsl:value-of select="$width"/>px</xsl:otherwise>
  2531.  
  2532. </xsl:choose>
  2533.  
  2534. </xsl:attribute>
  2535.  
  2536. </xsl:if>
  2537.  
  2538. </xsl:template>
  2539.  
  2540.  
  2541.  
  2542. <xsl:template name="process-cell-align">
  2543.  
  2544. <xsl:param name="align"/>
  2545.  
  2546. <xsl:if test="$align">
  2547.  
  2548. <xsl:attribute name="text-align">
  2549.  
  2550. <xsl:choose>
  2551.  
  2552. <xsl:when test="$align = 'char'">
  2553.  
  2554. <xsl:choose>
  2555.  
  2556. <xsl:when test="$align/../@char">
  2557.  
  2558. <xsl:value-of select="$align/../@char"/>
  2559.  
  2560. </xsl:when>
  2561.  
  2562. <xsl:otherwise>
  2563.  
  2564. <xsl:value-of select="'.'"/>
  2565.  
  2566. <!-- todo: it should depend on xml:lang ... -->
  2567.  
  2568. </xsl:otherwise>
  2569.  
  2570. </xsl:choose>
  2571.  
  2572. </xsl:when>
  2573.  
  2574. <xsl:otherwise>
  2575.  
  2576. <xsl:value-of select="$align"/>
  2577.  
  2578. </xsl:otherwise>
  2579.  
  2580. </xsl:choose>
  2581.  
  2582. </xsl:attribute>
  2583.  
  2584. </xsl:if>
  2585.  
  2586. </xsl:template>
  2587.  
  2588.  
  2589.  
  2590. <xsl:template name="process-cell-valign">
  2591.  
  2592. <xsl:param name="valign"/>
  2593.  
  2594. <xsl:if test="$valign">
  2595.  
  2596. <xsl:attribute name="display-align">
  2597.  
  2598. <xsl:choose>
  2599.  
  2600. <xsl:when test="$valign = 'middle'">center</xsl:when>
  2601.  
  2602. <xsl:when test="$valign = 'bottom'">after</xsl:when>
  2603.  
  2604. <xsl:when test="$valign = 'baseline'">auto</xsl:when>
  2605.  
  2606. <xsl:otherwise>before</xsl:otherwise>
  2607.  
  2608. </xsl:choose>
  2609.  
  2610. </xsl:attribute>
  2611.  
  2612. <xsl:if test="$valign = 'baseline'">
  2613.  
  2614. <xsl:attribute name="relative-align">baseline</xsl:attribute>
  2615.  
  2616. </xsl:if>
  2617.  
  2618. </xsl:if>
  2619.  
  2620. </xsl:template>
  2621.  
  2622.  
  2623.  
  2624. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2625.  
  2626. Inline-level
  2627.  
  2628. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  2629.  
  2630.  
  2631.  
  2632. <xsl:template match="b">
  2633.  
  2634. <fo:inline xsl:use-attribute-sets="b">
  2635.  
  2636. <xsl:call-template name="process-common-attributes-and-children"/>
  2637.  
  2638. </fo:inline>
  2639.  
  2640. </xsl:template>
  2641.  
  2642.  
  2643.  
  2644. <xsl:template match="strong">
  2645.  
  2646. <fo:inline xsl:use-attribute-sets="strong">
  2647.  
  2648. <xsl:call-template name="process-common-attributes-and-children"/>
  2649.  
  2650. </fo:inline>
  2651.  
  2652. </xsl:template>
  2653.  
  2654.  
  2655.  
  2656. <xsl:template match="strong//em | em//strong">
  2657.  
  2658. <fo:inline xsl:use-attribute-sets="strong-em">
  2659.  
  2660. <xsl:call-template name="process-common-attributes-and-children"/>
  2661.  
  2662. </fo:inline>
  2663.  
  2664. </xsl:template>
  2665.  
  2666.  
  2667.  
  2668. <xsl:template match="i">
  2669.  
  2670. <fo:inline xsl:use-attribute-sets="i">
  2671.  
  2672. <xsl:call-template name="process-common-attributes-and-children"/>
  2673.  
  2674. </fo:inline>
  2675.  
  2676. </xsl:template>
  2677.  
  2678.  
  2679.  
  2680. <xsl:template match="cite">
  2681.  
  2682. <fo:inline xsl:use-attribute-sets="cite">
  2683.  
  2684. <xsl:call-template name="process-common-attributes-and-children"/>
  2685.  
  2686. </fo:inline>
  2687.  
  2688. </xsl:template>
  2689.  
  2690.  
  2691.  
  2692. <xsl:template match="em">
  2693.  
  2694. <fo:inline xsl:use-attribute-sets="em">
  2695.  
  2696. <xsl:call-template name="process-common-attributes-and-children"/>
  2697.  
  2698. </fo:inline>
  2699.  
  2700. </xsl:template>
  2701.  
  2702.  
  2703.  
  2704. <xsl:template match="var">
  2705.  
  2706. <fo:inline xsl:use-attribute-sets="var">
  2707.  
  2708. <xsl:call-template name="process-common-attributes-and-children"/>
  2709.  
  2710. </fo:inline>
  2711.  
  2712. </xsl:template>
  2713.  
  2714.  
  2715.  
  2716. <xsl:template match="dfn">
  2717.  
  2718. <fo:inline xsl:use-attribute-sets="dfn">
  2719.  
  2720. <xsl:call-template name="process-common-attributes-and-children"/>
  2721.  
  2722. </fo:inline>
  2723.  
  2724. </xsl:template>
  2725.  
  2726.  
  2727.  
  2728. <xsl:template match="tt">
  2729.  
  2730. <fo:inline xsl:use-attribute-sets="tt">
  2731.  
  2732. <xsl:call-template name="process-common-attributes-and-children"/>
  2733.  
  2734. </fo:inline>
  2735.  
  2736. </xsl:template>
  2737.  
  2738.  
  2739.  
  2740. <xsl:template match="code">
  2741.  
  2742. <fo:inline xsl:use-attribute-sets="code">
  2743.  
  2744. <xsl:call-template name="process-common-attributes-and-children"/>
  2745.  
  2746. </fo:inline>
  2747.  
  2748. </xsl:template>
  2749.  
  2750.  
  2751.  
  2752. <xsl:template match="kbd">
  2753.  
  2754. <fo:inline xsl:use-attribute-sets="kbd">
  2755.  
  2756. <xsl:call-template name="process-common-attributes-and-children"/>
  2757.  
  2758. </fo:inline>
  2759.  
  2760. </xsl:template>
  2761.  
  2762.  
  2763.  
  2764. <xsl:template match="samp">
  2765.  
  2766. <fo:inline xsl:use-attribute-sets="samp">
  2767.  
  2768. <xsl:call-template name="process-common-attributes-and-children"/>
  2769.  
  2770. </fo:inline>
  2771.  
  2772. </xsl:template>
  2773.  
  2774.  
  2775.  
  2776. <xsl:template match="big">
  2777.  
  2778. <fo:inline xsl:use-attribute-sets="big">
  2779.  
  2780. <xsl:call-template name="process-common-attributes-and-children"/>
  2781.  
  2782. </fo:inline>
  2783.  
  2784. </xsl:template>
  2785.  
  2786.  
  2787.  
  2788. <xsl:template match="small">
  2789.  
  2790. <fo:inline xsl:use-attribute-sets="small">
  2791.  
  2792. <xsl:call-template name="process-common-attributes-and-children"/>
  2793.  
  2794. </fo:inline>
  2795.  
  2796. </xsl:template>
  2797.  
  2798.  
  2799.  
  2800. <xsl:template match="sub">
  2801.  
  2802. <fo:inline xsl:use-attribute-sets="sub">
  2803.  
  2804. <xsl:call-template name="process-common-attributes-and-children"/>
  2805.  
  2806. </fo:inline>
  2807.  
  2808. </xsl:template>
  2809.  
  2810.  
  2811.  
  2812. <xsl:template match="sup">
  2813.  
  2814. <fo:inline xsl:use-attribute-sets="sup">
  2815.  
  2816. <xsl:call-template name="process-common-attributes-and-children"/>
  2817.  
  2818. </fo:inline>
  2819.  
  2820. </xsl:template>
  2821.  
  2822.  
  2823.  
  2824. <xsl:template match="s">
  2825.  
  2826. <fo:inline xsl:use-attribute-sets="s">
  2827.  
  2828. <xsl:call-template name="process-common-attributes-and-children"/>
  2829.  
  2830. </fo:inline>
  2831.  
  2832. </xsl:template>
  2833.  
  2834.  
  2835.  
  2836. <xsl:template match="strike">
  2837.  
  2838. <fo:inline xsl:use-attribute-sets="strike">
  2839.  
  2840. <xsl:call-template name="process-common-attributes-and-children"/>
  2841.  
  2842. </fo:inline>
  2843.  
  2844. </xsl:template>
  2845.  
  2846.  
  2847.  
  2848. <xsl:template match="del">
  2849.  
  2850. <fo:inline xsl:use-attribute-sets="del">
  2851.  
  2852. <xsl:call-template name="process-common-attributes-and-children"/>
  2853.  
  2854. </fo:inline>
  2855.  
  2856. </xsl:template>
  2857.  
  2858.  
  2859.  
  2860. <xsl:template match="u">
  2861.  
  2862. <fo:inline xsl:use-attribute-sets="u">
  2863.  
  2864. <xsl:call-template name="process-common-attributes-and-children"/>
  2865.  
  2866. </fo:inline>
  2867.  
  2868. </xsl:template>
  2869.  
  2870.  
  2871.  
  2872. <xsl:template match="ins">
  2873.  
  2874. <fo:inline xsl:use-attribute-sets="ins">
  2875.  
  2876. <xsl:call-template name="process-common-attributes-and-children"/>
  2877.  
  2878. </fo:inline>
  2879.  
  2880. </xsl:template>
  2881.  
  2882.  
  2883.  
  2884. <xsl:template match="abbr">
  2885.  
  2886. <fo:inline xsl:use-attribute-sets="abbr">
  2887.  
  2888. <xsl:call-template name="process-common-attributes-and-children"/>
  2889.  
  2890. </fo:inline>
  2891.  
  2892. </xsl:template>
  2893.  
  2894.  
  2895.  
  2896. <xsl:template match="acronym">
  2897.  
  2898. <fo:inline xsl:use-attribute-sets="acronym">
  2899.  
  2900. <xsl:call-template name="process-common-attributes-and-children"/>
  2901.  
  2902. </fo:inline>
  2903.  
  2904. </xsl:template>
  2905.  
  2906.  
  2907.  
  2908. <xsl:template match="span">
  2909.  
  2910. <fo:inline>
  2911.  
  2912. <xsl:call-template name="process-common-attributes-and-children"/>
  2913.  
  2914. </fo:inline>
  2915.  
  2916. </xsl:template>
  2917.  
  2918.  
  2919.  
  2920. <xsl:template match="span[@dir]">
  2921.  
  2922. <fo:bidi-override direction="{@dir}" unicode-bidi="embed">
  2923.  
  2924. <xsl:call-template name="process-common-attributes-and-children"/>
  2925.  
  2926. </fo:bidi-override>
  2927.  
  2928. </xsl:template>
  2929.  
  2930.  
  2931.  
  2932. <xsl:template match="span[@style and contains(@style, 'writing-mode')]">
  2933.  
  2934. <fo:inline-container alignment-baseline="central"
  2935.  
  2936. text-indent="0pt"
  2937.  
  2938. last-line-end-indent="0pt"
  2939.  
  2940. start-indent="0pt"
  2941.  
  2942. end-indent="0pt"
  2943.  
  2944. text-align="center"
  2945.  
  2946. text-align-last="center">
  2947.  
  2948. <xsl:call-template name="process-common-attributes"/>
  2949.  
  2950. <fo:block wrap-option="no-wrap" line-height="1">
  2951.  
  2952. <xsl:apply-templates/>
  2953.  
  2954. </fo:block>
  2955.  
  2956. </fo:inline-container>
  2957.  
  2958. </xsl:template>
  2959.  
  2960.  
  2961.  
  2962. <xsl:template match="bdo">
  2963.  
  2964. <fo:bidi-override direction="{@dir}" unicode-bidi="bidi-override">
  2965.  
  2966. <xsl:call-template name="process-common-attributes-and-children"/>
  2967.  
  2968. </fo:bidi-override>
  2969.  
  2970. </xsl:template>
  2971.  
  2972.  
  2973.  
  2974. <xsl:template match="br">
  2975.  
  2976. <fo:block>
  2977.  
  2978. <xsl:call-template name="process-common-attributes"/>
  2979.  
  2980. </fo:block>
  2981.  
  2982. </xsl:template>
  2983.  
  2984.  
  2985.  
  2986. <xsl:template match="q">
  2987.  
  2988. <fo:inline xsl:use-attribute-sets="q">
  2989.  
  2990. <xsl:call-template name="process-common-attributes"/>
  2991.  
  2992. <xsl:choose>
  2993.  
  2994. <xsl:when test="lang('ja')">
  2995.  
  2996. <xsl:text>「</xsl:text>
  2997.  
  2998. <xsl:apply-templates/>
  2999.  
  3000. <xsl:text>」</xsl:text>
  3001.  
  3002. </xsl:when>
  3003.  
  3004. <xsl:otherwise>
  3005.  
  3006. <!-- lang('en') -->
  3007.  
  3008. <xsl:text>“</xsl:text>
  3009.  
  3010. <xsl:apply-templates/>
  3011.  
  3012. <xsl:text>”</xsl:text>
  3013.  
  3014. <!-- todo: other languages ...-->
  3015.  
  3016. </xsl:otherwise>
  3017.  
  3018. </xsl:choose>
  3019.  
  3020. </fo:inline>
  3021.  
  3022. </xsl:template>
  3023.  
  3024.  
  3025.  
  3026. <xsl:template match="q//q">
  3027.  
  3028. <fo:inline xsl:use-attribute-sets="q-nested">
  3029.  
  3030. <xsl:call-template name="process-common-attributes"/>
  3031.  
  3032. <xsl:choose>
  3033.  
  3034. <xsl:when test="lang('ja')">
  3035.  
  3036. <xsl:text>『</xsl:text>
  3037.  
  3038. <xsl:apply-templates/>
  3039.  
  3040. <xsl:text>』</xsl:text>
  3041.  
  3042. </xsl:when>
  3043.  
  3044. <xsl:otherwise>
  3045.  
  3046. <!-- lang('en') -->
  3047.  
  3048. <xsl:text>‘</xsl:text>
  3049.  
  3050. <xsl:apply-templates/>
  3051.  
  3052. <xsl:text>’</xsl:text>
  3053.  
  3054. </xsl:otherwise>
  3055.  
  3056. </xsl:choose>
  3057.  
  3058. </fo:inline>
  3059.  
  3060. </xsl:template>
  3061.  
  3062.  
  3063.  
  3064. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  3065.  
  3066. Image
  3067.  
  3068. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  3069.  
  3070.  
  3071.  
  3072. <xsl:template match="img">
  3073.  
  3074. <fo:external-graphic xsl:use-attribute-sets="img">
  3075.  
  3076. <xsl:call-template name="process-img"/>
  3077.  
  3078. </fo:external-graphic>
  3079.  
  3080. </xsl:template>
  3081.  
  3082.  
  3083.  
  3084. <xsl:template match="img[ancestor::a/@href]">
  3085.  
  3086. <fo:external-graphic xsl:use-attribute-sets="img-link">
  3087.  
  3088. <xsl:call-template name="process-img"/>
  3089.  
  3090. </fo:external-graphic>
  3091.  
  3092. </xsl:template>
  3093.  
  3094.  
  3095.  
  3096. <xsl:template name="process-img">
  3097.  
  3098. <xsl:attribute name="src">
  3099.  
  3100. <xsl:text>url('</xsl:text>
  3101.  
  3102. <xsl:value-of select="@src"/>
  3103.  
  3104. <xsl:text>')</xsl:text>
  3105.  
  3106. </xsl:attribute>
  3107.  
  3108. <xsl:if test="@alt">
  3109.  
  3110. <xsl:attribute name="role">
  3111.  
  3112. <xsl:value-of select="@alt"/>
  3113.  
  3114. </xsl:attribute>
  3115.  
  3116. </xsl:if>
  3117.  
  3118. <xsl:if test="@width">
  3119.  
  3120. <xsl:choose>
  3121.  
  3122. <xsl:when test="contains(@width, '%')">
  3123.  
  3124. <xsl:attribute name="width">
  3125.  
  3126. <xsl:value-of select="@width"/>
  3127.  
  3128. </xsl:attribute>
  3129.  
  3130. <xsl:attribute name="content-width">scale-to-fit</xsl:attribute>
  3131.  
  3132. </xsl:when>
  3133.  
  3134. <xsl:otherwise>
  3135.  
  3136. <xsl:attribute name="content-width">
  3137.  
  3138. <xsl:value-of select="@width"/>px</xsl:attribute>
  3139.  
  3140. </xsl:otherwise>
  3141.  
  3142. </xsl:choose>
  3143.  
  3144. </xsl:if>
  3145.  
  3146. <xsl:if test="@height">
  3147.  
  3148. <xsl:choose>
  3149.  
  3150. <xsl:when test="contains(@height, '%')">
  3151.  
  3152. <xsl:attribute name="height">
  3153.  
  3154. <xsl:value-of select="@height"/>
  3155.  
  3156. </xsl:attribute>
  3157.  
  3158. <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
  3159.  
  3160. </xsl:when>
  3161.  
  3162. <xsl:otherwise>
  3163.  
  3164. <xsl:attribute name="content-height">
  3165.  
  3166. <xsl:value-of select="@height"/>px</xsl:attribute>
  3167.  
  3168. </xsl:otherwise>
  3169.  
  3170. </xsl:choose>
  3171.  
  3172. </xsl:if>
  3173.  
  3174. <xsl:if test="@border">
  3175.  
  3176. <xsl:attribute name="border">
  3177.  
  3178. <xsl:value-of select="@border"/>px solid</xsl:attribute>
  3179.  
  3180. </xsl:if>
  3181.  
  3182. <xsl:call-template name="process-common-attributes"/>
  3183.  
  3184. </xsl:template>
  3185.  
  3186.  
  3187.  
  3188. <xsl:template match="object">
  3189.  
  3190. <xsl:apply-templates/>
  3191.  
  3192. </xsl:template>
  3193.  
  3194.  
  3195.  
  3196. <xsl:template match="param"/>
  3197.  
  3198. <xsl:template match="map"/>
  3199.  
  3200. <xsl:template match="area"/>
  3201.  
  3202. <xsl:template match="label"/>
  3203.  
  3204. <xsl:template match="input"/>
  3205.  
  3206. <xsl:template match="select"/>
  3207.  
  3208. <xsl:template match="optgroup"/>
  3209.  
  3210. <xsl:template match="option"/>
  3211.  
  3212. <xsl:template match="textarea"/>
  3213.  
  3214. <xsl:template match="legend"/>
  3215.  
  3216. <xsl:template match="button"/>
  3217.  
  3218.  
  3219.  
  3220. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  3221.  
  3222. Link
  3223.  
  3224. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  3225.  
  3226.  
  3227.  
  3228. <xsl:template match="a">
  3229.  
  3230. <fo:inline>
  3231.  
  3232. <xsl:call-template name="process-common-attributes-and-children"/>
  3233.  
  3234. </fo:inline>
  3235.  
  3236. </xsl:template>
  3237.  
  3238.  
  3239.  
  3240. <xsl:template match="a[@href]">
  3241.  
  3242. <fo:basic-link xsl:use-attribute-sets="a-link">
  3243.  
  3244. <xsl:call-template name="process-a-link"/>
  3245.  
  3246. </fo:basic-link>
  3247.  
  3248. </xsl:template>
  3249.  
  3250.  
  3251.  
  3252. <xsl:template name="process-a-link">
  3253.  
  3254. <xsl:call-template name="process-common-attributes"/>
  3255.  
  3256. <xsl:choose>
  3257.  
  3258. <xsl:when test="starts-with(@href,'#')">
  3259.  
  3260. <xsl:attribute name="internal-destination">
  3261.  
  3262. <xsl:value-of select="substring-after(@href,'#')"/>
  3263.  
  3264. </xsl:attribute>
  3265.  
  3266. </xsl:when>
  3267.  
  3268. <xsl:otherwise>
  3269.  
  3270. <xsl:attribute name="external-destination">
  3271.  
  3272. <xsl:text>url('</xsl:text>
  3273.  
  3274. <xsl:value-of select="@href"/>
  3275.  
  3276. <xsl:text>')</xsl:text>
  3277.  
  3278. </xsl:attribute>
  3279.  
  3280. </xsl:otherwise>
  3281.  
  3282. </xsl:choose>
  3283.  
  3284. <xsl:if test="@title">
  3285.  
  3286. <xsl:attribute name="role">
  3287.  
  3288. <xsl:value-of select="@title"/>
  3289.  
  3290. </xsl:attribute>
  3291.  
  3292. </xsl:if>
  3293.  
  3294. <xsl:apply-templates/>
  3295.  
  3296. </xsl:template>
  3297.  
  3298.  
  3299.  
  3300. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  3301.  
  3302. Ruby
  3303.  
  3304. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  3305.  
  3306.  
  3307.  
  3308. <xsl:template match="ruby">
  3309.  
  3310. <fo:inline-container alignment-baseline="central"
  3311.  
  3312. block-progression-dimension="1em"
  3313.  
  3314. text-indent="0pt"
  3315.  
  3316. last-line-end-indent="0pt"
  3317.  
  3318. start-indent="0pt"
  3319.  
  3320. end-indent="0pt"
  3321.  
  3322. text-align="center"
  3323.  
  3324. text-align-last="center">
  3325.  
  3326. <xsl:call-template name="process-common-attributes"/>
  3327.  
  3328. <fo:block font-size="50%"
  3329.  
  3330. wrap-option="no-wrap"
  3331.  
  3332. line-height="1"
  3333.  
  3334. space-before.conditionality="retain"
  3335.  
  3336. space-before="-1.1em"
  3337.  
  3338. space-after="0.1em"
  3339.  
  3340. role="rt">
  3341.  
  3342. <xsl:for-each select="rt | rtc[1]/rt">
  3343.  
  3344. <xsl:call-template name="process-common-attributes"/>
  3345.  
  3346. <xsl:apply-templates/>
  3347.  
  3348. </xsl:for-each>
  3349.  
  3350. </fo:block>
  3351.  
  3352. <fo:block wrap-option="no-wrap" line-height="1" role="rb">
  3353.  
  3354. <xsl:for-each select="rb | rbc[1]/rb">
  3355.  
  3356. <xsl:call-template name="process-common-attributes"/>
  3357.  
  3358. <xsl:apply-templates/>
  3359.  
  3360. </xsl:for-each>
  3361.  
  3362. </fo:block>
  3363.  
  3364. <xsl:if test="rtc[2]/rt">
  3365.  
  3366. <fo:block font-size="50%"
  3367.  
  3368. wrap-option="no-wrap"
  3369.  
  3370. line-height="1"
  3371.  
  3372. space-before="0.1em"
  3373.  
  3374. space-after.conditionality="retain"
  3375.  
  3376. space-after="-1.1em"
  3377.  
  3378. role="rt">
  3379.  
  3380. <xsl:for-each select="rt | rtc[2]/rt">
  3381.  
  3382. <xsl:call-template name="process-common-attributes"/>
  3383.  
  3384. <xsl:apply-templates/>
  3385.  
  3386. </xsl:for-each>
  3387.  
  3388. </fo:block>
  3389.  
  3390. </xsl:if>
  3391.  
  3392. </fo:inline-container>
  3393.  
  3394. </xsl:template>
  3395.  
  3396. </xsl:stylesheet>
  3397.  

39.html file

  1.  
  2. <html>
  3. <title>
  4. SOFTCell
  5. </title>
  6. <body>
  7. <table border="1" summary="">
  8. <tr>
  9. <td>One</td>
  10. <td>Two</td>
  11. <td>Three</td>
  12. </tr>
  13. </table>
  14. </body>
  15. </html>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC