4.2. Paperboy Extension Module: New XSLT functions

Paperboy registers extra XSLT functions that you can use in your XSLT templates. You need to register the http://sourceforge.net/projects/paperboy/ namespace and register the extension module for it in your template before you can use them however.

To register a namespace in XML you give an element an "xmlns" attribute which specifies the prefix abbreviation you want associated with the namespace (or none for the default namespace) and the URI of the namespace. Children of the element you give this attribute to will inherit it so it's usually best to define namespaces for the root element.

So more specifically, in Paperboy's case you would add an xmlns:paperboy="http://sourceforge.net/projects/paperboy/" attribute to your <xsl:stylesheet> element which would associate the namespace with the prefix "paperboy:". If you wanted to use a different prefix you can just change it to something else; the prefix is only a symbolic abbreviation for the URI.

Now that you have the namespace registered, you need to tell the XSLT that the namespace will provide XPath extensions modules (i.e. new XPath functions) rather than just being used for elements and attributes. To do this, you set the <xsl:stylesheet>'s extension-element-prefixes attribute. (You can also call it "xsl:extension-element-prefixes" but the namespace is unnecessary since <xsl:stylesheet> already specifies the namespace.) The attribute is a white-space-delimited list of all the namespace prefixes, so if you need to register other extensions you'd put them all in the single attribute.

Thus, the whole <xsl:stylesheet> could look like this:


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:paperboy="http://sourceforge.net/projects/paperboy/"
extension-element-prefixes="paperboy">
			

4.2.1. paperboy:config(arg)

This is a function that takes an argument and passes it to 'paperboy-config', this can be useful in finding where such things as Paperboy-specific DTDs are stored on your system.

4.2.2. paperboy:dotted_version()

Prints the version number of paperboy.

4.2.3. paperboy:is_new(node)

Takes a node and determines if it is new since the last time the file was processed.

4.2.4. paperboy:sortable_time(type, node)

This function takes a time and converts it to a time suitable for sorting. The type argument should be a feed type ('RSS', 'RDF', or 'ATOM'), and the node argument is the node where the time is contained.

Warning

This function is still experimental and its interface might change in the future.

4.2.5. paperboy:ctimef(format, time[, tzd])

This function takes the time in time and formats it according to format. The output is usually in UTC format, but if tzd is specified it will be the local timezone. Format is the same format as used by C's strftime() function. Time must be in W3CDTF (W3C's Date and Time Formats), or can be the special string 'now'. TZD can be in one of many formats: '+hh', '+hhmm', '+hh:mm' where the sign can be positive or negative, hh are the hours and mm are the minutes.

Warning

This function is still experimental and its interface might change in the future.