Transforming XSQL Page Results with XSLT
Since the data page that results from executing the queries in your XSQL page template is an XML document, and since XSLT offers a robust, declarative mechanism for transforming XML documents into anything else, we can put the two together to achieve a highly effective one-two punch:
The XSQL page assembles XML information relevant to the task at hand.
The XSLT stylesheet transforms it into an appropriate format for delivery.
We’ll look at a few examples in this section that illustrate this approach.
Associating a Stylesheet with an XSQL Page
To associate an
XSLT stylesheet with an XSQL page, we
use the standard technique prescribed by the W3C (see http://www.w3.org/TR/xml-stylesheet), the
<?xml-stylesheet?> processing instruction. It goes after the
<?xml version="1.0"?> declaration and before the document
element in your XSQL page. It must include as attributes two key
pieces of information required to identify the stylesheet:
hrefattribute that describes the absolute or relative location of the desired stylesheet
text/xsl" attribute that indicates the type of stylesheet in use
<?xml-stylesheet?> instruction of type
"text/xsl" in your XSQL page causes the XML
document obtained by expanding the XSQL page’s
<xsql:query> tags to be transformed by the indicated stylesheet
in the server before returning the results to the requester. Only an
<?xml-stylesheet?> instruction with an attribute of
type="text/xsl" will be considered ...