XDC - v. 0.6.1

File util.xsl

<xsl:stylesheet version="1.0" exclude-result-prefixes="java"/>

The 'util.xsl' stylesheet contains a number of utility templates like templates for string and path handling as well as several templates used for displaying relevant data of XML elements.
Since:
0.5
Version:
0.5
Author:
Jens Voß


Template Summary
<xsl:template match="/" mode="util.extractValue">
  <xsl:param name="str"/>
  <xsl:param name="leftDelim"/>
  <xsl:param name="rightDelim"/>
</xsl:template>

This template extracts a substring from a given string.

<xsl:template match="/" mode="util.getPath">
  <xsl:param name="currentPackage"/>
  <xsl:param name="relativePath"/>
</xsl:template>

This template "re-bases" a relative path.

<xsl:template match="*" mode="util.postprocessMemberNames">
  <xsl:param name="memberNames"/>
</xsl:template>

The template 'util.postprocessMemberNames' is used to generate a correct member name list in case the original member name list is one of the wildcard expressions '*' or '**'.

<xsl:template match="*" mode="util.displayStartLine">
  <xsl:param name="indent"/>
  <xsl:param name="href"/>
  <xsl:param name="end"/>
</xsl:template>

This template is used to print out the opening tag (including all attributes) of a documented XML element.

<xsl:template match="*" mode="util.displayEndLine">
  <xsl:param name="indent"/>
</xsl:template>

The 'util.displayEndLine' template is used to display the closing tag of a documented XML element.

<xsl:template match="*" mode="util.displayNode">
  <xsl:param name="depth" select="1"/>
  <xsl:param name="indent"/>
  <xsl:param name="href"/>
  <xsl:param name="subelementNames"/>
</xsl:template>

This template is used to print out an XML element including a configurable set of its subelements (up to a configurable depth).

<xsl:template match="/" mode="util.getFirstSentence">
  <xsl:param name="text"/>
</xsl:template>

This template is used to extract the first sentence from a text which is given as a template parameter.

<xsl:template match="*" mode="util.getLink"/>

This templates creates a name for an XML element which can be used for interlinking parts of the documentation.

<xsl:template match="*" mode="util.reportMissing">
  <xsl:param name="file"/>
  <xsl:param name="package"/>
</xsl:template>

This template prints out a warning message for an XML node which has no XDC comment.

<xsl:template match="/" mode="util.findEnd">
  <xsl:param name="text"/>
  <xsl:param name="char"/>
</xsl:template>

This template is used to find the position of the first occurrence of a specified character within an XPath expression, not counting occurrences in substrings "protected" by delimiting characters.

<xsl:template match="/" mode="util.escapeSingleQuotes">
  <xsl:param name="text"/>
</xsl:template>

This is a utility template which escapes all occurrences of single quotation marks by a backslash.


Template Detail
<xsl:template match="/" mode="util.extractValue">
  <xsl:param name="str"/>
  <xsl:param name="leftDelim"/>
  <xsl:param name="rightDelim"/>
</xsl:template>

This template extracts a substring from a given string. It "returns" the first occurrence of a substring bounded by a pair of given delimiting strings.

Parameters:
str - The original string
leftDelim - The left delimiting string
rightDelim - The right delimiting string


<xsl:template match="/" mode="util.getPath">
  <xsl:param name="currentPackage"/>
  <xsl:param name="relativePath"/>
</xsl:template>

This template "re-bases" a relative path. It resets the base of the path from the base of the documented API to the current package (which is also expressed as a relative path based on the same API root.

Example:
If the value of the currentPackage parameter is net/sf/xdc/xsl and that of the relativePath parameter is net/sf/xdc/resources/stylesheet.css, then this method will return ../../../../net/sf/xdc/resources/stylesheet.css.

Parameters:
currentPackage - The relative path of the package of the currently documented file
relativePath - The path (relative to the root dir of the documented API) of the file to be "re-based"


<xsl:template match="*" mode="util.postprocessMemberNames">
  <xsl:param name="memberNames"/>
</xsl:template>

The template 'util.postprocessMemberNames' is used to generate a correct member name list in case the original member name list is one of the wildcard expressions '*' or '**'. In the other cases, this template simply copies the original memberNames parameter.

Parameters:
memberNames - The original member name list


<xsl:template match="*" mode="util.displayStartLine">
  <xsl:param name="indent"/>
  <xsl:param name="href"/>
  <xsl:param name="end"/>
</xsl:template>

This template is used to print out the opening tag (including all attributes) of a documented XML element.

Parameters:
indent - The indentation string to be used by this template
href - An optional hyperlink. If this is empty, the template displays the start line as a plain text; otherwise it creates an <a>-Element with the complete start line as content.
end - A flag determining whether the start line is the same as the end line


<xsl:template match="*" mode="util.displayEndLine">
  <xsl:param name="indent"/>
</xsl:template>

The 'util.displayEndLine' template is used to display the closing tag of a documented XML element.

Parameters:
indent - The indentation string to be used by this template


<xsl:template match="*" mode="util.displayNode">
  <xsl:param name="depth" select="1"/>
  <xsl:param name="indent"/>
  <xsl:param name="href"/>
  <xsl:param name="subelementNames"/>
</xsl:template>

This template is used to print out an XML element including a configurable set of its subelements (up to a configurable depth).

Parameters:
depth - The depth up to which subelements are to be included. This defaults to 1 (and is decremented in recursive template calls).
indent - The indentation string for the context node. This defaults to the empty string (and is incremented in recursive template calls).
href - An optional hyperlink. If present, the first line of the printed XML element is displayed as the content of an <a>-Element.
subelementNames - A comma separated list of subelement names which are to be included in the displayed XML element


<xsl:template match="/" mode="util.getFirstSentence">
  <xsl:param name="text"/>
</xsl:template>

This template is used to extract the first sentence from a text which is given as a template parameter. The sentence returned is the smallest substring of the original text which starts at the beginning and ends with a the first period sign (.) followed by whitespace or an opening left bracket (<). If no such period sign exists in the original text, the full text is returned.

Parameters:
text - The original text from which the first sentence is to be extracted


<xsl:template match="*" mode="util.getLink"/>

This templates creates a name for an XML element which can be used for interlinking parts of the documentation. Unlike the links between element summary descriptions and their detailed descriptions (which are created by simply numbering the nodes in the order of occurrence), this template creates a name from all the element's attributes by concatenating the element name with a sequence of all attribute names and values, separated by a tilde (~), with the attribute names sorted alphabetically and blanks in the attribute values omitted.
Example: The return value of this template for a the element
<myNode yourAttr="attr one" ourAttr="attr two"/>
is myNode~outAttr~attrtwo~yourAttr~attrone


<xsl:template match="*" mode="util.reportMissing">
  <xsl:param name="file"/>
  <xsl:param name="package"/>
</xsl:template>

This template prints out a warning message for an XML node which has no XDC comment.

Parameters:
file - The name of the file in which the node with the missing comment is detected
package - The name of the package in which the node with the missing comment is detected


<xsl:template match="/" mode="util.findEnd">
  <xsl:param name="text"/>
  <xsl:param name="char"/>
</xsl:template>

This template is used to find the position of the first occurrence of a specified character within an XPath expression, not counting occurrences in substrings "protected" by delimiting characters. This "protection" follows these rules:

  1. Whitespace is "protected" by opening and closing brackets ("[" and "]"),
  2. Closing brackets are "protected" by single quotation marks ("'"),
  3. Single quotation marks cannot be protected.
The template is applied recursively (with different char parameters) to detect the first occurrence of whitespace in the "normalized" version of the text parameter; if this value contains no whitespace, then the length of the normalized text is returned.


<xsl:template match="/" mode="util.escapeSingleQuotes">
  <xsl:param name="text"/>
</xsl:template>

This is a utility template which escapes all occurrences of single quotation marks by a backslash.


XDC - v. 0.6.1

Copyright © 2005 - 2006 Jens Voß.