Xalan XSLT transformer object


Usage:

OBJECT x = CREATE "dynamic", "dynxalan"

If an application wishes to use the Xalan XSLT transformer object then it should load it once and keep it loaded. Loading it each time it is used is very inefficient.

The writeToString method as implemented in KCML 6.20 has a memory leak. See the notes on the method on how to avoid it.

For further information see http://xml.apache.org/xalan-c/index.html


xslroot
XalanTransformer
XSLTInputSource
InputStream
XSLTResultTarget
OutputStream
XalanCompiledStylesheet
XalanParsedSource
FormatterListener
FormatterToXercesDOM
DOMStringPrintWriter
XalanString
SAXParser
ContentHandler
ScanToken
Attributes
Parser
Document
Node
Implementation
DocumentType
Text
CDATASection
Comment
DocumentFragment
EntityReference
ProcessingInstruction
CharacterData
Attr
Element
NamedNodeMap
NodeList
TreeWalker
NodeIterator
NodeFilter
MemBufInputSource
Writer
MemBufOutput
WriterFilter
ImplementationLS

xslroot

Xalan XML root object

MethodReturnsPurpose
CreateTransformer()XalanTransformerCreates transformer object
CreateXercesDOMParser()ParserCreates a Xerces DOM parser objectKCML
CreateXercesSAXParser()SAXParserCreates a Xerces SAX2 parser objectKCML
getDOMImplementation(name$)ImplementationReturn an Implementation ref from DOM Implementation RegistryKCML
PropertyTypeReturnsPurpose
ImplementationRImplementationReturn an Implementation refKCML

XalanTransformer

XalanTransformer object

MethodReturnsPurpose
CompileStylesheetObject(OBJECT src)XalanCompiledStylesheetCompile a stylesheetKCML
FormatterToXercesDOM(OBJECT doc, OBJECT currentElement)FormatterToXercesDOMConstructor for FormatterToXercesDOM object.KCML
InputSourceFile(file$)XSLTInputSourceConstructor for InputSource object using a filenameKCML
InputSourceStream(OBJECT stream)XSLTInputSourceConstructor for InputSource object using an InputStreamKCML
InputStream(file$)InputStreamConstructor for InputStream object using a stringKCML
ParseSourceObject(OBJECT src, bUseXercesDOM)XalanParsedSourceCompile a stylesheetKCML
ResultTarget()XSLTResultTargetConstructor for XSLTResultTarget object.KCML
ResultTargetFile(file$)XSLTResultTargetConstructor for XSLTResultTarget object using a filename. If the file already exists it will be truncated.KCML
ResultTargetFormatter(OBJECT flistener)XSLTResultTargetConstructor for XSLTResultTarget object using a FormatterListener object.KCML
ResultTargetStream(OBJECT stream)XSLTResultTargetConstructor for XSLTResultTarget object using an OutputStream.KCML
ResultTargetWriter(OBJECT string)XSLTResultTargetConstructor for XSLTResultTarget object using a DOMStringPrintWriter object.KCML
StringWriter(OBJECT string)DOMStringPrintWriterConstructor for DOMStringPrintWriter.KCML
TransformCompiled(OBJECT src, OBJECT xsl, OBJECT dst)integerApply the compiled stylesheet to the input source and write the transformation output to the target.KCML
TransformFile(src$, xsl$, dst$)integerTransform using filesKCML
TransformFile(src$, dst$)integerTransform using files and an embedded stylesheetKCML
TransformParsed(OBJECT src, OBJECT xsl, OBJECT dst)integerApply the stylesheet to the preparsed input source and write the transformation output to the target.KCML
TransformParsedCompiled(OBJECT src, OBJECT xsl, OBJECT dst)integerApply the compiled stylesheet to the preparsed input source and write the transformation output to the target.KCML
XalanString(string$)XalanStringConstructor for a string objectKCML
XalanString()XalanStringConstructor for an empty string objectKCML
destroyParsedSource(OBJECT obj)integerDestroy a compiled XML source document
destroyStylesheet(OBJECT obj)integerDestroy a compiled stylesheet
setStylesheetParam(key$, expression$)voidSet a top level stylesheet parameter. Enclose strings in single quotes.
transform(OBJECT src, OBJECT xsl, OBJECT dst)integerApply the stylesheet source object to the input source object and write the transformation output to the target object.
transform(OBJECT src, OBJECT dst)integerApply an embedded stylesheet to the input source object and write the transformation output to the target object.
PropertyTypeReturnsPurpose
IndentRWintegerGet/set indent space count
LastError$RstringReturn text of last error
UseValidationRWboolGet/set UseValidation flag specifying whether source documents should be validated.

XSLTInputSource

Memory based input stream object


InputStream

Input stream object


XSLTResultTarget

Memory based output stream object

PropertyTypeReturnsPurpose
EncodingRWXalanStringGet/Set encoding for target
FileNameWXalanStringSet filename for target
FormatterListenerRWFormatterListenerGet/Set formatter

OutputStream

Output stream object


XalanCompiledStylesheet

Compiled stylesheet object


XalanParsedSource

Compiled XML document object


FormatterListener

Output formatter

Downcastable from the following interfaces:

FormatterToXercesDOM


FormatterToXercesDOM

Xerces document output formatter

Extends FormatterListener


DOMStringPrintWriter

A writer object that prints to an XalanDOMString


XalanString

Unicode string object

MethodReturnsPurpose
set(string$)voidSet string contents
str$()stringGet string contents

SAXParser

SAX2 Parser object

MethodReturnsPurpose
ContentHandler()ContentHandlerConstructor for a SAX2 ContentHandler objectKCML
createScanToken()ScanTokenAllocate a ScanToken for use in a progressive parseKCML
getFeature(name$)boolQuery the state of a SAX2 feature
getProperty$(name$)stringQuery the state of a SAX2 property
parse(URI$)voidParse a URI
parseFirst(URI$, OBJECT token)boolStart a progressive parse of a URI
parseFirstIS(OBJECT stream, OBJECT token)boolStart a progressive parse of an InputStream
parseIS(OBJECT stream)voidParse from an InputStream
parseNext(OBJECT token)boolContinue a progressive parse
parseReset(OBJECT token)voidReset the parser after a progressive parse
setContentHandler(OBJECT handler)voidSpecify the SAX2 ContentHandler
setFeature(name$, value)voidSpecify the state of a SAX2 feature
setProperty(name$, value$)voidSpecify the state of a SAX2 property
PropertyTypeReturnsPurpose
ErrorCountRintGet error count from last parse
ExitOnFirstFatalErrorRWboolGet/set Exit On First Fatal Error flag
ValidationConstraintFatalRWboolGet/set Validation Constraint Fatal flag

ContentHandler

Object that receives callbacks from SAX2 events

MethodReturnsPurpose
SetCharacters(fn)voidSet KCML handler subroutine for characters
SetEndDocument(fn)voidSet KCML handler subroutine for end of document
SetEndElement(fn)voidSet KCML handler subroutine for end of element
SetIgnorableWhitespace(fn)voidSet KCML handler subroutine for DTD defined ignorable whitespace
SetResetDocument(fn)voidSet KCML handler subroutine for restart of document
SetStartDocument(fn)voidSet KCML handler subroutine for start of document
SetStartElement(fn)voidSet KCML handler subroutine for start of element
CallbackReturnsPurpose
characters(text$, length)voidReceive notification of text. Note that the length is the number of UTF-16 characters in the string. To get the length in bytes use LEN(STR(text$)). This handler may be called more than once for a text string which contains entities.
endDocument()voidReceive notification of end of document
endElement(uri$, localname$, qname$)voidReceive notification of end of every element
ignorableWhitespace(text$, length)voidReceive notification of DTD defined ignorable whitespace
resetDocument()voidReceive notification of restart of document
startDocument()voidReceive notification of start of document
startElement(uri$, localname$, qname$, attributes)voidReceive notification of start of every element, uri$ is the combination of the NS and the tag as a URI, localname$ is the bare tag name, qname$ is the tag with its prefix,attributes is an object containing any attributes for the tag

ScanToken

Scan state token for progressive parsing


Attributes

A list of attributes for an element as returned by SAX2

MethodReturnsPurpose
Index(qname$)integerReturns the index of an attribute in the list by qualified name
Index(uri$, localpart$)integerReturns the index of an attribute in the list by namespace name
LocalName$(index)stringReturns the local name of an attribute in the list by index (0 based)
QName$(index)stringReturns the qualified name of an attribute in the list by index (0 based)
Type$(qname$)stringReturns the type of an attribute in the list by qualified name. The attribute type is one of the strings 'CDATA', 'ID', 'IDREF', 'IDREFS', 'NMTOKEN', 'NMTOKENS', 'ENTITY', 'ENTITIES', or 'NOTATION' (always in upper case).
URI$(index)stringReturns the namespace URI of an attribute in the list by index (0 based)
Value$(index)stringReturns the value of an attribute in the list by position
PropertyTypeReturnsPurpose
LengthRunsigned intReturns the number of elements in the list

Parser

Parser object

MethodReturnsPurpose
MemBufInputSource(buf, buflen, id)MemBufInputSourceConstructor for a memory buffer input stream
adoptDocument()DocumentAdopt DOM document, caller now responsible for releasing memory
applyTranslations()intApply translations to currently loaded DOMKCML
parse(URI$)voidParse a URI
parseIS(OBJECT stream)voidParse from an inputstreamKCML
reset()voidReset parser state ready for another parse
resetDocumentPool()voidFree parser memory
PropertyTypeReturnsPurpose
CreateEntityReferenceNodesRWboolGet/set flag controlling expansion of entities
DoNamespacesRWboolGet/set process namespaces flag
DoSchemaRWboolGet/set Process schemas flag
DocumentRDocumentReturn document object
ErrorCountRintGet error count from last parse
ExitOnFirstFatalErrorRWboolGet/set Exit On First Fatal Error flag
ExternalNoNamespaceSchemaLocation$RWstringGet/set location of an external schema or DTD
ExternalSchemaLocation$RWstringGet/set location of an external schema or DTD. There can be a list of more than one. It matches the target namespace of the instance document.
IncludeIgnorableWhitespaceRWboolGet/set flag controlling how whitespace is treated (requires DTD)
LoadExternalDTDRWboolGet/set flag to control loading of an external DTD. If the DTD is referenced only for consistency checking and is not needed during the parse, say to supply entities, then set this flag to FALSE.
ValidationConstraintFatalRWboolGet/set Validation Constraint Fatal flag
ValidationSchemeRWValSchemeGet/set validation scheme

Document

DOM Document object

Multiply inherits from among the following interfaces:

Node

MethodReturnsPurpose
adoptNode(OBJECT source)NodeAdopt a node from another document by changing the ownerDocument of the node and its children
createAttribute(name$)AttrCreate a new attribute node with given name
createAttributeNS(namespaceURI$, qualname$)AttrCreate a new attribute node with given name
createCDATASection(data$)CDATASectionCreate a new CDATA node for given data
createComment(text$)CommentCreate a new Comment node for given text
createDocumentFragment()DocumentFragmentCreate an empty DocumentFragment object
createElement(tagname$)ElementCreate a new Element node
createElementNS(namespaceURI$, qualname$)ElementCreate a new Element node
createEntityReference(name$)EntityReferenceCreate a new Entity reference node
createNodeFilter()NodeFilterCreate a node filter objectKCML
createNodeIterator(OBJECT root, whatToShow, OBJECT filter, entityReferenceExpansion)NodeIteratorCreate a flat tree NodeIterator
createProcessingInstruction(target$, data$)ProcessingInstructionCreate a new Processing Instruction node
createTextNode(data$)TextCreate a new Text node
createTreeWalker(OBJECT root, whatToShow, OBJECT filter, entityReferenceExpansion)TreeWalkerCreate a TreeWalker iterator
createWriterFilter()WriterFilterCreate a serialization WriterFilter objectKCML
getElementById(id$)ElementReturn element matching an ID
getElementsByTagName(pattern$)NodeListMake node list of elements matching a tag name or '*'. It does not support XPath.
getElementsByTagNameNS(NsURI$, localname$)NodeListGet a node list object of descendent objects by name
importNode(OBJECT importnode, deep)NodeImport a node from another document
normalizeDocument()voidNormalize a document as if it had been saved and loaded again
renameNode(OBJECT source, NsURI$, newname$)NodeRename a node
PropertyTypeReturnsPurpose
DoctypeRDocumentTypeReturns the document type declaration
DocumentElementRElementReturns the documents root element
DocumentURI$RWstringGet/set document location, NULL if undefined
ImplementationRImplementationReturns the implementation object that handles the doc
InputEncoding$RstringGet/set actual encoding of document
StrictErrorCheckingRWboolGet/set error checking on node operations
XmlEncoding$RstringGet/set document encoding
XmlStandaloneRWboolGet/set standalone
XmlVersion$RWstringGet/set document version string

Node

DOM Node object

Downcastable from the following interfaces:

Text
Element
CharacterData
DocumentType
Attr

MethodReturnsPurpose
appendChild(OBJECT newChild)NodeAdd child to list of children
cloneNode(deep)NodeClone this node
hasChildNodes()boolReturn true if node has children
insertBefore(OBJECT newChild, OBJECT refChild)NodeInsert node before existing child node
isSupported(feature$, version$)boolSupports a specified function
normalize()voidNormalize children
release()voidFree resourcesXerces
removeChild(OBJECT oldChild)NodeDelete child oldchild from the list of children and return it
replaceChild(OBJECT newChild, OBJECT oldChild)NodeReplace existing child with newchild and return oldChild
PropertyTypeReturnsPurpose
AttributesRNamedNodeMapReturn a list of the attributes of the node or NULL
ChildNodesRNodeListReturn all children in a nodelist
FirstChildRNodeReturn first child of a node
LastChildRNodeReturn last child of a node
LocalName$RstringReturn local part of the qualified name of this node
NamespaceURI$RstringReturn namespace URI for node tag
NextSiblingRNodeReturn next sibling of a node
NodeName$RstringReturn name of a node (with any NS prefix)
NodeTypeRintReturn type of a node
NodeValue$RstringReturn value of a node, depending on type
OwnerDocumentRDocumentGet the document associated with this node
ParentNodeRNodeReturn parent of a node
Prefix$RWstringGet/set namespace prefix of this node
PreviousSiblingRNodeReturn previous sibling of a node

Implementation

DOM Implementation object

Downcastable from the following interfaces:

ImplementationLS

MethodReturnsPurpose
createDocument(NamespaceURI$, qualifiedName$, OBJECT doctype)DocumentCreates a new XML Document object
createDocument()DocumentCreates a nameless XML document object
createDocumentType(qualifiedName$, publicId$, systemId$)DocumentTypeCreates a new XML DocumentType object
hasFeature(feature$, version$)boolreturns TRUE if a feature is supported
PropertyTypeReturnsPurpose
ImplementationRImplementationReturn a Implementation ref for this object

DocumentType

DOM Document type object

Extends Node

PropertyTypeReturnsPurpose
EntitiesRNamedNodeMapReturn a NamedNodeMap of the entities declared in the DTD
InternalSubset$RstringReturn internal subset as a string
Name$RstringReturn name of the DTD
NotationsRNamedNodeMapReturn a NamedNodeMap of the notations declared in the DTD
PublicId$RstringReturn public ID of external subset
SystemId$RstringReturn system ID of external subset

Text

DOM Text object

Extends CharacterData

MethodReturnsPurpose
isIgnorableWhitespace()boolReturns TRUE if node contains only ignorable whitespace (requires a DTD)
isWhitespace()boolReturns TRUE if node contains only whitespaceKCML
splitText(offset)TextSplits node into two at offset

CDATASection

DOM CDATA object

Extends Text


Comment

DOM Comment object

Extends CharacterData


DocumentFragment

DOM DocumentFragment object

DocumentFragment is a lightweight Document object allowing a program to extract part of a document tree or create a small object that looks like a Node without the overhead of a Document object.

In operations, such as inserting Nodes as children of other Nodes, that take Nodes as arguments, a DocumentFragment may be passed resulting in all the child nodes of the DocumentFragment being moved to the child list of this node.

DocumentFragment nodes do not need to be well-formed XML documents (although they do need to follow the rules imposed upon well-formed XML parsed entities, which can have multiple top nodes). For example, a DocumentFragment might have only one child and that child node could be a Text node. Such a structure model represents neither an HTML document nor a well-formed XML document.

When a DocumentFragment is inserted into a Document (or indeed any other Node that may take children) the children of the DocumentFragment and not the DocumentFragment itself are inserted into the Node. This makes the DocumentFragment very useful when the user wishes to create nodes that are siblings; the DocumentFragment acts as the parent of these nodes so that the user can use the standard methods from the Node interface, such as insertBefore() and appendChild().

Extends Node


EntityReference

DOM EntityReference object

Extends Node


ProcessingInstruction

DOM ProcessingInstruction object

Extends Node

PropertyTypeReturnsPurpose
Data$RWstringGet/set data of the element
Target$RstringReturn target of the element

CharacterData

DOM Character object

Extends Node

MethodReturnsPurpose
appendData(newdata$)voidAppends character data to end of node
deleteData(offset, count)voidDeletes character data at the offset in the node
insertData(offset, newdata$)voidInserts character data at the offset in the node
replaceData(offset, count, newdata$)voidReplaces character data at the offset in the node
substringData$(offset, count)stringReturns a substring of character data for node
PropertyTypeReturnsPurpose
Data$RstringReturn data of the element
LengthRunsigned intReturn count of chars in the text

Attr

DOM Attribute object

Extends Node

PropertyTypeReturnsPurpose
Name$RstringReturn name of the attribute
OwnerElementRElementReturn Element node the attribute is attached to or NULL if none
SpecifiedRboolReturn TRUE if the attribute was explicitly specified rather than assumed from the DTD default
Value$RWstringGet/set value of the attribute

Element

DOM Element object

Extends Node

MethodReturnsPurpose
getAttribute$(name$)stringGet attribute of element by name
getAttributeNS$(NsURI$, localname$)stringGet attribute of element by name
getAttributeNode(name$)AttrGet a Attr node object by name
getAttributeNodeNS(NsURI$, localname$)AttrGet a Attr node object by name
getElementsByTagName(name$)NodeListGet a node list object of descendent objects by name
getElementsByTagNameNS(NsURI$, localname$)NodeListGet a node list object of descendent objects by name
removeAttribute(name$)voidRemove attribute of element by name
removeAttributeNS(NsURI$, localname$)voidRemove attribute of element by name
removeAttributeNode(OBJECT name)AttrRemove specified Attr node
setAttribute(name$, value$)voidSet attribute of element by name
setAttributeNS(NsURI$, qualname$, value$)voidSet attribute of element by name
setAttributeNode(OBJECT newattr)AttrAdds or replaces an Attr node
setAttributeNodeNS(OBJECT newattr)AttrAdds or replaces an Attr node
PropertyTypeReturnsPurpose
TagName$RstringReturn name of the element (including any NS prefix).

NamedNodeMap

DOM Named Node Map object

This collection can be iterated with FOR OBJECT ... NEXT OBJECT

MethodReturnsPurpose
getNamedItem(name$)NodeReturn node with given name
item(index)NodeReturn node with given index
PropertyTypeReturnsPurpose
LengthRunsigned intReturn count of nodes in the map

NodeList

DOM Node List object

This collection can be iterated with FOR OBJECT ... NEXT OBJECT

MethodReturnsPurpose
item(index)NodeReturn node with given index
PropertyTypeReturnsPurpose
LengthRunsigned intReturn count of nodes in a node list

TreeWalker

DOM TreeWalker object

MethodReturnsPurpose
firstChild()NodeMoves to first child and returns the node
getCurrentNode()NodeGet node at which the NodeWalker is positioned
lastChild()NodeMoves to last child and returns the node
nextNode()NodeMoves to and returns next node in list
nextSibling()NodeMoves to next sibling and returns the node
parentNode()NodeMoves to and returns the closest visible ancestor node of the current node in list
previousNode()NodeMoves to and returns previous node in list
previousSibling()NodeMoves to previous sibling and returns the node
setCurrentNode(OBJECT node)voidSet node at which the NodeWalker is positioned
PropertyTypeReturnsPurpose
ExpandEntityReferencesRboolReturn original ExpandEntityReferences flag
WhatToShowRintegerReturn bitmap of node types included

NodeIterator

DOM NodeIterator object

MethodReturnsPurpose
nextNode()NodeReturn next node in list
previousNode()NodeReturn previous node in list
PropertyTypeReturnsPurpose
ExpandEntityReferencesRboolReturn original ExpandEntityReferences flag
WhatToShowRintegerReturn bitmap of node types included

NodeFilter

Object that receives filter callbacks from NodeIterator and TreeWalker

The acceptNode() callback function returns one of the following enumeration
DIM _FILTER_ACCEPT=1, _FILTER_REJECT=2, _FILTER_SKIP=3

MethodReturnsPurpose
SetFilter(fn)voidSet KCML callback for filtering a node
CallbackReturnsPurpose
acceptNode(node)integer

MemBufInputSource

Memory buffer based input stream object


Writer

Used to serialize a document

Features supported

This table is taken from the Apache Xerces documentation

normalize-characters true [ optional] (default) Perform the W3C Text Normalization of the characters in document as they are written out. Only the characters being written are (potentially) altered. The DOM document itself is unchanged.
false [required] do not perform character normalization.
split-cdata-sections true [required] (default) Split CDATA sections containing the CDATA section termination marker ']]>' or characters that can not be represented in the output encoding, and output the characters using numeric character references. If a CDATA section is split a warning is issued.
false [ required] Signal an error if a CDATASection contains an unrepresentable character.
validation true [ optional] Use the abstract schema to validate the document as it is being serialized. If validation errors are found the error handler is notified about the error. Setting this state will also set the feature use-abstract-schema to true.
false [ required] (default) Don't validate the document as it is being serialized.
expand-entity-references true [ optional] Expand EntityReference nodes when serializing.
false [required] (default) Serialize all EntityReference nodes as XML entity references.
whitespace-in-element-content true [required] ( default) Output all white spaces in the document.
false [ optional] Only output white space that is not within element content. The implementation is expected to use the isWhitespaceInElementContent flag on Text nodes to determine if a text node should be written out or not.
discard-default-content true [required] (default ) Use whatever information available to the implementation (i.e. XML schema, DTD, the specified flag on Attr nodes, and so on) to decide what attributes and content should be serialized or not. Note that the specified flag on Attr nodes in itself is not always reliable, it is only reliable when it is set to false since the only case where it can be set to false is if the attribute was created by a Level 1 implementation.
false [required] Output all attributes and all content.
format-canonical true [optional] This formatting writes the document according to the rules specified in DOM3. Setting this feature to true will set the feature "format-pretty-print" to false.
false [required] (default) Don't canonicalize the output.
format-pretty-print true [optional] Formatting the output by adding whitespace to produce a pretty-printed, indented, human-readable form. The exact form of the transformations is not specified by this specification. Setting this feature to true will set the feature "format-canonical" to false.
false [required] (default) Don't pretty-print the result.
MethodReturnsPurpose
canSetFeature(feature$, value)boolIndicates whether setting a feature to a particular value will be supportedDOM3
getFeature(feature$)boolGet the value of a standardized featureDOM3
release()voidFree resources. Redundant, do not useObsolete
setFeature(feature$, value)voidSet the value of a standardized featureDOM3
setFilter(OBJECT filter)voidApply a WriterFilter object to filter the serialized outputDOM3
writeDocToString(OBJECT doc)MemBufOutputSerialize a UTF-8 encoded document to a string objectKCML
writeToString(OBJECT node)MemBufOutputSerialize a node to a string object.

Note that in 6.20 KCML this method returns a string not an object and that this string will never be deleted causing a memory leak. In build 21043 the method as described here was added with the name writeToStringObject so that existing application code will continue to work but the new method is recommended to avoid the memory leak.

DOM3
PropertyTypeReturnsPurpose
NewLine$RWstringGet/Set end-of-line sequence to use when serializing. Only HEX(0A), HEX(0D) and HEX(0D0A) are acceptable. NULL means OS default.DOM3

MemBufOutput

String object

PropertyTypeReturnsPurpose
Text$RstringReturn UTF-8 textKCML

WriterFilter

Object that receives filter callbacks during serialization

The acceptNode() callback function returns the same enumeration as the NodeFilter callbacks namely
DIM _FILTER_ACCEPT=1, _FILTER_REJECT=2, _FILTER_SKIP=3

MethodReturnsPurpose
SetFilter(fn)voidSet KCML callback for filtering a node
CallbackReturnsPurpose
acceptNode(node)integer
PropertyTypeReturnsPurpose
WhatToShowRWintegerGet/Set types of nodes to be serialized

ImplementationLS

Factory methods for DOM Writer object

Extends Implementation

MethodReturnsPurpose
createDOMWriter()WriterCreate a Writer serializing objectDOM3