juno.xml.xsl Module

Provides supprt for Extensible Stylesheet Transformation (XSLT) transforms.

Licence
See licence.txt for use and distribution terms.

class XsltException: object.Exception;

The exception thrown when an error occurs while processing an XSLT transformation.

this(string message = null, int lineNumber = 0, int linePosition = 0, string sourceUri = null);

Initializes a new instance.

Parameters
string message
The description of the error.
cause
The Exception that threw the XsltException.

final int lineNumber();

Gets the line number indicating where the error occurred.

Returns
The line number indicating where the error occurred.

final int linePosition();

Gets the line position indicating where the error occurred.

Returns
The line position indicating where the error occurred.

char[] sourceUri();

Gets the location path of the style sheet.

Returns
The location path of the style sheet.

class XsltSettings;

Specifies the XSLT features to support during execution of the style sheet.

bool enableDocumentFunction;

Indicates whether to enable support for the XSLT document() function.

bool enableScript;

Indicates whether to enable support for embedded script blocks.

class XsltArgumentList;

Contains a variable number of arguments that are either XSLT parameters or extension objects.

void addParam(T)(string name, string namespaceUri, T parameter);

Adds a parameter and associates it with the namespace-qualified name.

Parameters
name
The name to associate with the parameter.
namespaceUri
The namespace URI to associate with the parameter.
parameter
The parameter value to add to the list.

T getParam(T)(string name, string namespaceUri);

Gets the parameter associated with the namespace-qualified name.

Parameters
name
The name of the parameter.
namespaceUri
The namespace URI associated with the parameter.

Returns
The parameter or T.init if one was not found.

T removeParam(T)(string name, string namespaceUri);

Removes the parameter.

Parameters
name
The name of the parameter to remove.
namespaceUri
The namespace URI of the parameter to remove.

Returns
The parameter or T.init if one was not found.

void addExtensionObject(char[] namespaceUri, Object extension);

Adds a new object and associates it with the namespace URI.

Parameters
char[] namespaceUri
The namespace URI to associate with the object.
Object extension
The object to add to the list.

Object getExtensionObject(char[] namespaceUri);

Gets the object associated with the specified namespace URI.

Parameters
char[] namespaceUri
The namespace URI of the object.

Returns
The object or null if one was not found.

Object removeExtensionObject(char[] namespaceUri);

Removes the object associated with the specified namespace URI.

Parameters
char[] namespaceUri
The namespace URI of the object.

Returns
The object or null if one was not found.

void clear();

Removes all parameters and extension objects.

class XslTransform;

Transforms XML data using an XSLT style sheet.

Examples
:
 // Load the style sheet.
 scope stylesheet = new XslTransform;
 stylesheet.load("output.xsl");

 // Execute the transform and output the results to a file.
 stylesheet.transform("books.xml", "books.html");

this();

Initializes a new instance.

void load(char[] stylesheetUri, XsltSettings settings = cast(XsltSettings)null);

Loads the style sheet located at the specified URI.

Parameters
char[] stylesheetUri
The URI of the style sheet.
XsltSettings settings
The features to apply to the style sheet.

Throws
XsltException if the style sheet contains an error.

void transform(char[] inputUri, char[] resultsFile);

Executes the transform using the input document specified by the URI and outputs the results to a file.

Parameters
char[] inputUri
The URI of the input document.
char[] resultsFile
The URI of the output document.

void transform(char[] inputUri, XsltArgumentList arguments, Stream results);

Executes the transform using the input document specified by the URI and outputs the results to a stream.

Parameters
char[] inputUri
The URI of the input document.
XsltArgumentList arguments
The namespace-qualified arguments used as input to the transform.
Stream results
The stream to output.

Examples
: The following example shows how to write the results to an XmlDocument.
 // The resulting document.
 scope resultDoc = new XmlDocument;

 // Load the transform.
 scope stylesheet = new XslTransform;
 stylesheet.load("output.xsl");

 // Save the results to a MemoryStream.
 scope ms = new MemoryStream;
 stylesheet.transform("books.xml", null, ms);

 // Load the results into the document.
 resultDoc.load(ms);

void transform(XmlDocument input, XsltArgumentList arguments, Stream results);

Executes the transform using the specified input document and outputs the results to a stream.

Parameters
XmlDocument input
The document containing the data to be transformed.
XsltArgumentList arguments
The namespace-qualified arguments used as input to the transform.
Stream results
The stream to output.