Library Template Reference

Norman Walsh

$Id: lib.html,v 1.1 2007/09/19 15:49:42 malo_pichot Exp $


Introduction

This is technical reference documentation for the DocBook XSL Stylesheets; it documents (some of) the parameters, templates, and other elements of the stylesheets.

This is not intended to be “user” documentation. It is provided for developers writing customization layers for the stylesheets, and for anyone who's interested in “how it works”.

Although I am trying to be thorough, this documentation is known to be incomplete. Don't forget to read the source, too :-)

Table of Contents

string.subst - Substitute one text string for another in a string
xpointer.idref - Extract IDREF from an XPointer
length-magnitude - Return the unqualified dimension from a length specification
length-units - Return the units from a length specification
length-spec - Return a fully qualified length specification
pi-attribute - Extract a pseudo-attribute from a PI
lookup.key - Retrieve the value associated with a particular key in a table
xpath.location - Calculate the XPath child-sequence to the current node

Name

string.subst — Substitute one text string for another in a string

Synopsis

<xsl:template name="string.subst">
<xsl:param name="string"/>
<xsl:param name="target"/>
<xsl:param name="replacement"/>
  ...
</xsl:template>

The string.subst template replaces all occurances of target in string with replacement and returns the result.


Name

xpointer.idref — Extract IDREF from an XPointer

Synopsis

<xsl:template name="xpointer.idref">
<xsl:param name="xpointer">http://...</xsl:param>
  ...
</xsl:template>

The xpointer.idref template returns the ID portion of an XPointer which is a pointer to an ID within the current document, or the empty string if it is not.

In other words, xpointer.idref returns “foo” when passed either #foo or #xpointer(id('foo')), otherwise it returns the empty string.


Name

length-magnitude — Return the unqualified dimension from a length specification

Synopsis

<xsl:template name="length-magnitude">
<xsl:param name="length" select="'0pt'"/>
  ...
</xsl:template>

The length-magnitude template returns the unqualified length ("20" for "20pt") from a dimension.


Name

length-units — Return the units from a length specification

Synopsis

<xsl:template name="length-units">
<xsl:param name="length" select="'0pt'"/>
<xsl:param name="default.units" select="'pt'"/>
  ...
</xsl:template>

The length-units template returns the units ("pt" for "20pt") from a length. If no units are supplied on the length, the defauilt.units are returned.


Name

length-spec — Return a fully qualified length specification

Synopsis

<xsl:template name="length-spec">
<xsl:param name="length" select="'0pt'"/>
<xsl:param name="default.units" select="'pt'"/>
  ...
</xsl:template>

The length-spec template returns the qualified length from a dimension. If an unqualified length is given, the default.units will be added to it.


Name

pi-attribute — Extract a pseudo-attribute from a PI

Synopsis

<xsl:template name="pi-attribute">
<xsl:param name="pis" select="processing-instruction('')"/>
<xsl:param name="attribute">filename</xsl:param>
<xsl:param name="count">1</xsl:param>
  ...
</xsl:template>

The pi-attribute template extracts a pseudo-attribute from a processing instruction. For example, given the PI “<?foo bar="1" baz='red'?>”,

<xsl:call-template name="pi-attribute">
  <xsl:with-param name="pis" select="processing-instruction('foo')"/>
  <xsl:with-param name="attribute" select="'baz'"/>
</xsl:call-template>

will return “red”. This template returns the first matching attribute that it finds. Presented with processing instructions that contain badly formed pseudo-attributes (missing or unbalanced quotes, for example), the template may silently return erroneous results.


Name

lookup.key — Retrieve the value associated with a particular key in a table

Synopsis

<xsl:template name="lookup.key">
<xsl:param name="key" select="''"/>
<xsl:param name="table" select="''"/>
  ...
</xsl:template>

Given a table of space-delimited key/value pairs, the lookup.key template extracts the value associated with a particular key.


Name

xpath.location — Calculate the XPath child-sequence to the current node

Synopsis

<xsl:template name="xpath.location">
<xsl:param name="node" select="."/>
<xsl:param name="path" select="''"/>
  ...
</xsl:template>

The xpath.location template calculates the absolute path from the root of the tree to the current element node.