| ||||
DescriptionThe following function argument conversions are performed:* An XPath string object is mapped to an ECMAScript string
value. The following conversions are performed on return values: * An ECMAScript string value or String object is mapped to an
XPath string object.
| ||||
See Also
|
| ||
SummaryAn example how to use the DOM in JavaScript extension functions. The function returns a sum of all attributes in a nodeset. | ||
ExampleTemplate: -------------------- <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:func="http://www.exslt.org/functions" xmlns:my="http://gingerall.org/sablot/myfunc" extension-element-prefixes="func" exclude-result-prefixes="my"> <xsl:output method="xml" indent="yes"/> <func:script implements-prefix="my" language="javascript"><![CDATA[ function attrSum(nodeset) { var sum = 0; for (i = 0; i < nodeset.length; i++) { for (j = 0; j < nodeset[i].attributes.length; j++) { sum += Number(nodeset[i].attributes.item(j)); } } return sum; } ]]> <xsl:fallback> <xsl:text>JS extension no supported!</xsl:text> </xsl:fallback> </func:script> <xsl:template match="/root"> <root> <xsl:choose> <xsl:when test="function-available('my:attrSum')"> <xsl:text>The sum of attributes: </xsl:text> <xsl:value-of select="my:attrSum(node)"/> </xsl:when> <xsl:otherwise>Function not available!</xsl:otherwise> </xsl:choose> </root> </xsl:template> </xsl:stylesheet> Data: -------------------- <?xml version="1.0"?> <root> <node a="1" b="2"/> <node c="10"/> <node a="5" b="6" c="7"/> </root> Result: -------------------- <?xml version="1.0" encoding="UTF-8"?> <root>The sum of attributes: 31</root> | ||
See Also
|
| ||||||
SummaryThis reference guide describes the DOM API for Sablotron Extension functions in JavaScript. Sablotron supports an extension element funct:script element (where funct prefix is bound to the 'http://www.exslt.org/functions' namespace URI) with language="ecmascript" or language="javascript". | ||||||
DescriptionThe API implementation follows the ECMAScript/DOM2 Language Binding defined in DOM Level2, Appendix E.However, there are few exceptions from the specifications: * The DOM model is read only As the model is read-only and because of distinctions in the DOM and the XPath models, some objects can't be ever instantiated. Those objects (DocumentFragment, Text, Comment, CDATASection, DocumentType, Notation, Entity, EntityReference, ProcessingInstruction) are not supported.
See
Type | ||||||
See Also
|
| ||||
DescriptionA global objectXSLTContext provides an access to XSLT
and XPath expession context.
The following DOM objects are available: | ||||
See Also
|
| ||||
DescriptionAttr has the all the properties and methods of theNode object
as well as the properties and methods defined below.
The Attr object has the following properties:
| ||||
See Also
|
| ||||||
Syntaxname
| ||||||
See Also
|
| ||||||
SyntaxownerElement
| ||||||
See Also
|
| ||||||
Syntaxspecified
| ||||||
See Also
|
| ||||||
Syntaxvalue
| ||||||
NotesThis property can raise aDOMException object on setting.
| ||||||
See Also
|
| ||||
DescriptionCharacterData has the all the properties and methods of theNode
object as well as the properties and methods defined below.
The CharacterData object has the following properties:
The CharacterData object has the following methods:
| ||||
See Also
|
| ||||||
Syntaxdata
| ||||||
NotesThis property can raise aDOMException object on setting and can
raise a DOMException object on retrieval.length
| ||||||
See Also
|
| ||||||
Syntaxlength
| ||||||
See Also
|
| ||||||||||||
SyntaxsubstringData(offset, count)
| ||||||||||||
NotesThis method can raise aDOMException object.
The very first item has index 0.
| ||||||||||||
See Also
|
| ||||
DescriptionThe DOMException object has the following properties:DOMException.code The DOMException class has the following constants:
DOMException.INDEX_SIZE_ERR, type Number, value 1. | ||||
See Also
|
| ||||||
Syntaxcode
| ||||||
NotesThis function always returns FALSE currently. | ||||||
See Also
|
| ||||
DescriptionThe DOMImplementation object has the following methods:DOMImplementation.hasFeature() | ||||
See Also
|
| ||||||||||||
SyntaxhasFeature(feature, version)
| ||||||||||||
DescriptionThis function always returns FALSE currently. | ||||||||||||
See Also
|
| ||||
DescriptionDocument has the all the properties and methods of theNode
object as well as the properties and methods defined below.
The Document object has the following properties: | ||||
See Also
|
| ||||||
SyntaxdocumentElement
| ||||||
See Also
|
| ||||||
Syntaximplementation
| ||||||
See Also
|
| ||||
DescriptionElement has the all the properties and methods of theNode
object as well as the properties and methods defined below.
The Element object has the following properties:
The Element object has the following methods:
| ||||
See Also
|
| |||||||||
SyntaxgetAttribute(name)
| |||||||||
See Also
|
| |||||||||
SyntaxgetAttributeNode(name)
| |||||||||
See Also
|
| |||||||||
SyntaxhasAttribute(name)
| |||||||||
See Also
|
| ||||||
SyntaxtagName
| ||||||
See Also
|
| ||||
DescriptionThe NamedNodeMap object has the following properties:NamedNodeMap.length
The NamedNodeMap object has the following methods:
| ||||
See Also
|
| |||||||||
SyntaxgetNamedItem(name)
| |||||||||
See Also
|
| |||||||||
Syntaxitem(index)
| |||||||||
NotesThe very first item has index 0. | |||||||||
See Also
|
| ||||||
Syntaxlength
| ||||||
See Also
|
| ||||
DescriptionThe Node object has the following properties:Node.nodeName Node.nodeValue Node.nodeType Node.parentNode Node.childNodes Node.firstChild Node.lastChild Node.previousSibling Node.nextSibling Node.attributes Node.ownerDocument Node.namespaceURI Node.prefix Node.localName
The Node object has the following methods: The Node class has the following constants:
Node.ELEMENT_NODE, type Number, value 1. | ||||
See Also
|
| ||||||
Syntaxattributes
| ||||||
See Also
|
| ||||||
SyntaxchildNodes
| ||||||
See Also
|
| ||||||
SyntaxfirstChild
| ||||||
See Also
|
| ||||||
SyntaxhasAttributes()
| ||||||
See Also
|
| ||||||
SyntaxhasChildNodes()
| ||||||
See Also
|
| ||||||||||||
SyntaxisSupported(feature, version)
| ||||||||||||
NotesThis function always returns FALSE currently. | ||||||||||||
See Also
|
| ||||||
SyntaxlastChild
| ||||||
See Also
|
| ||||||
SyntaxlocalName
| ||||||
See Also
|
| ||||||
SyntaxnamespaceURI
| ||||||
See Also
|
| ||||||
SyntaxnextSibling
| ||||||
See Also
|
| ||||||
SyntaxnodeName
| ||||||
See Also
|
| ||||||
SyntaxnodeType
| ||||||
DescriptionSeeNode class constants.
| ||||||
See Also
|
| ||||||
SyntaxnodeValue
| ||||||
NotesThis property can raise aDOMException object on setting and can
raise a DOMException object on retrieval.
| ||||||
See Also
|
| ||||||
SyntaxownerDocument
| ||||||
See Also
|
| ||||||
SyntaxparentNode
| ||||||
See Also
|
| ||||||
Syntaxprefix
| ||||||
NotesThis property can raise aDOMException object on setting.
| ||||||
See Also
|
| ||||||
SyntaxpreviousSibling
| ||||||
See Also
|
| ||||
DescriptionThe NodeList object has the following properties:NodeList.length
The NodeList object has the following methods:
| ||||
See Also
|
| |||||||||
Syntaxitem(index)
| |||||||||
NotesThis object can also be dereferenced using square bracket notation (e.g. obj[1]). Dereferencing with an integer index is equivalent to invoking the item method with that index. The very first item has index 0. | |||||||||
See Also
|
| ||||||
Syntaxlength
| ||||||
See Also
|
| ||||
DescriptionThe XSLTContext global object has the following properties:XSLTContext.contextNode XSLTContext.contextPosition XSLTContext.contextSize XSLTContext.currentNode XSLTContext.ownerDocument | ||||
See Also
|
| ||||||
SyntaxcontextNode
| ||||||
See Also
|
| ||||||
SyntaxcontextPosition
| ||||||
See Also
|
| ||||||
SyntaxcontextSize
| ||||||
See Also
|
| ||||||
SyntaxcurrentNode
| ||||||
See Also
|
| ||||||
SyntaxownerDocument
| ||||||
See Also
|