XSLT and HTML::Template::XPath

PageKit Templates use HTML::Template::XPath to include Content from the XML files. In addition, PageKit Templates themselves can be generated from the XML using XSLT stylesheets. Currently the only supported XSLT processer is XML::LibXSLT which uses Gnome libxslt library.

You should use HTML::Template::XPath when you would like to separate some Content from the View, but do not want to go the full route of using XSLT.

On the other hand, if you are starting from scratch, have existing XML and XSLT files, or have complicated transformation needs, then XSLT is probably the way to go.

XSLT

To use XSLT, you must place the Content XML files in the Content/ directory, and the View XSLT files in the View/ directory. You must specify the XSLT template that you would like to use using the xml-stylesheet processing instruction by placing the following on the top of your XML file:

     <?xml-stylesheet type="text/xsl" href="my_xslt_file.xsl"?>
    

Note that the XSLT file specified in the href attribute is relative to the View/pkit_view/ or the View/Default/ directory.

All of the input request parameters are available to the XSLT file by using the xsl:param tag in the top level of the file.

The output of XSL Transformation should be a PageKit Template or a HTML/XML/WML file (which is a special case of a PageKit Template file, namely one without any PageKit tags). Note that the Data from the Model gets filled in after the XSL transformation. This is done for performance reasons - the XSL tranformation can be cached, even if the data from the model is updated.

HTML::Template::XPath

Using HTML::Template::XPath is easy with PageKit, it is build into the PageKit Template by using <CONTENT_VAR> and <CONTENT_LOOP> tags, which contain XPath queries to the Content XML data.

The Content XML file defaults to Content/page_id.xml or can be specified using XPath's document() function.