XMLTemplate Objects |
Active Web |
The XMLTemplate object is used in conjunction with the XMLTransform Object to perform XSLT (Extensible Stylesheet Language Transformations). XSLT is a functional programming language which specifies the rules by which to transform an XML document into another text document, which maybe, but not necessarily an XML document.
An XML transformation requires two inputs the XSLT and the XML document to transform. The XMLTemplate Object is the first of these inputs and holds the XSLT, an XMLTransform Object that conforms to this template can then be requested to perform the transformation. The advantage of this tiered approach is that the threadsafe XMLTemplate objects, which will tend to be static, can be cached and then reused for multiple transformations.
Property |
Description |
error |
An error message If an error has occurred. If no error has occurred then it will be null. The error messages are explained below: Insufficient number of parameters - The constructor has been called without the correct number of arguments. Unable to resolve parameter to file.- The XSL file parameter sent to the constructor could not be resolved to a file could not be found. Failed to get resource as stream – The XSL file parameter sent to the constructor, resolved to a file, but that file could not be opened. While accessing files the operating system can generate various other error messages. Failed to build template source – The XSL specified in the constructors file parameter did not appear to be valid. No template available – This error will be produced when calling newTransform when an error during construction has resulted in there being no template loaded. Failed to build transformer from template - This error will be produced when calling newTransform when an error has occurred in building a transformation for the XSL provided. |
prototype |
A reference to the Object Prototype. This property does not enumerate and can not be deleted, but it can be changed. |
Function |
Description |
newTransform() |
Returns an XMLTransform object for the XSL specified at construction. |
The XMLTemplate constructor is used to create new XMLTemplate objects.
var myXMLTemplate = new XMLTemplate(myXSL.xsl);
A new XMLTemplate object is created using the xsl file supplied as the transformation template.
Shown below is the XMLTemplate object prototype chain.
When the constructor is run as a function without the new operator it has exactly the same behaviour as using the new operator.
Constructor properties are read only (they can not be changed or deleted) and it is not possible to add new properties to the Constructor.
Property |
Description |
prototype |
A reference to the Object Prototype. This property does not enumerate and can not be changed or deleted. |
error |
Property referring set on construction if an error occurs building the template. |
The XMLTemplate constructor has no predefined functions.
Topic ID: 150118