Jump to content

XQuery/Converting HTML tables to XSL-FO tables

From Wikibooks, open books for an open world

Motivation

[edit | edit source]

You have a collection of HTML tables that you want to convert to PDF.

Method

[edit | edit source]

We will use an XQuery typeswitch transformation that will convert the key table elements (table,thead,tr,th,db,tbody) to the corresponding XSL-FO elements.

Sample Main Dispatcher

[edit | edit source]

We will create an XQuery module with the following functions:

  • a main dispater[check spelling] function for starting the transform
  • a single function for each table element
  • a function to process the class attributes for each element

To transform the table the following will be used:

  let $fo-table := html-2-fo:main($html-table);

The main function of the