XML Reference Manual
- Previous Page XSD Miscellaneous
- Next Page DOM Node Types
XML Reference Manual
- Node type
- Node object
- NodeList object
- NamedNodeMap object
- Document object
- Element object
- Attr object
- Text object
- CDATASection object
- Comment object
- XMLHttpRequest object
- XSD elements
- Define the handling of whitespace characters (newlines, carriage returns, spaces, and tabs).
- XSLT, XPath, and XQuery Functions
Node type
The following table lists different W3C node types and the child elements they can have:
Node type | Description | Child elements |
---|---|---|
Document | Represents the entire document (the root node of the DOM tree) |
|
DocumentFragment | Represents a lightweight Document object that contains a part of the document. |
|
DocumentType | Provides an interface to the entity defined for the document. | None |
ProcessingInstruction | Represents a processing instruction. | None |
EntityReference | Represents an entity reference element. |
|
Element | Represents an element (element) element |
|
Attr | Represents an attribute. |
|
Text | Represents the text content in an element or attribute. | None |
CDATASection | Represents a CDATA section in the document (text that is not parsed by the parser) | None |
Comment | Represents a comment. | None |
Entity | Represents an entity. |
|
Notation | Represents a symbol declared in the DTD. | None |
Node type - The returned value
The following table lists the values that the nodeName and nodeValue properties can return for each node type:
Node type | Return value of nodeName | Return value of nodeValue |
---|---|---|
Document | #document | null |
DocumentFragment | #document fragment | null |
DocumentType | Doctype name | null |
EntityReference | Entity reference name | null |
Element | Element name | null |
Attr | Attribute name | Attribute value |
ProcessingInstruction | target | Content of the node |
Comment | #comment | Annotation text |
Text | #text | Node Content |
CDATASection | #cdata-section | Node Content |
Entity | Entity Name | null |
Notation | Symbol Name | null |
NodeTypes - Named Constants
NodeType | Named Constant |
---|---|
1 | ELEMENT_NODE |
2 | ATTRIBUTE_NODE |
3 | TEXT_NODE |
4 | CDATA_SECTION_NODE |
5 | ENTITY_REFERENCE_NODE |
6 | ENTITY_NODE |
7 | PROCESSING_INSTRUCTION_NODE |
8 | COMMENT_NODE |
9 | DOCUMENT_NODE |
10 | DOCUMENT_TYPE_NODE |
11 | DOCUMENT_FRAGMENT_NODE |
12 | NOTATION_NODE |
XML DOM Node Object
Properties of Node object
Properties | Description |
---|---|
attributes | Contains the NamedNodeMap of this node's attributes (if this node is an element). |
baseURI | Returns the absolute base URI of the node. |
childNodes | Returns the NodeList of child nodes of the node. |
firstChild | Returns the first child node of the node. |
lastChild | Returns the last child node of the node. |
nextSibling | Returns the immediate following sibling node of the node. |
nodeName | Return the name of the node, based on its type. |
nodeType | Return the type of the node. |
nodeValue | Set or return the value of the node, based on its type. |
ownerDocument | Returns the root element of the node (document object). |
parentNode | Returns the parent node of the node. |
prefix | Sets or returns the namespace prefix of the node. |
previousSibling | Returns the immediate preceding sibling node of the node. |
textContent | Sets or returns the text content of the node and its descendants. |
Methods of Node object
Method | Description |
---|---|
appendChild() | Appends a new child node to the end of the node's child node list. |
cloneNode() | Clones a node. |
compareDocumentPosition() | Compares the position of two nodes in the DOM hierarchy (document). |
getFeature()feature,version) | Returns a DOM object that implements the specialized API for the specified feature and version. |
getUserData()key) |
Returns the object associated with the key on the node. The object must be set to this node first, by calling setUserData with the same key. |
hasAttributes() | Returns true if the specified node has any attributes, otherwise returns false. |
hasChildNodes() | Returns true if the specified node has child nodes, otherwise returns false. |
insertBefore() | Inserts a new child node before the specified child node. |
isDefaultNamespace(URI) | Returns whether the specified namespace URI is the default. |
isEqualNode() | Checks if two nodes are equal. |
isSameNode() | Checks if two nodes are the same node. |
lookupNamespaceURI() | Returns the namespace URI associated with the given prefix. |
lookupPrefix() | Returns the prefix associated with the given namespace URI. |
normalize() | Merges adjacent text nodes and deletes empty text nodes. |
removeChild() | Deletes (and returns) the specified child node of the current node. |
replaceChild() | Replaces the child node with a new node. |
setUserData(key,data,handler) | Associates an object with a key on the node. |
XML DOM NodeList Object
Properties of NodeList object
Properties | Description |
---|---|
length | Returns the number of nodes in the NodeList. |
Methods of NodeList object
Method | Description |
---|---|
item() | Returns the node at the specified index in the NodeList. |
XML DOM NamedNodeMap Object
Properties of NamedNodeMap object
Properties | Description |
---|---|
length | Return the number of nodes in the list. |
Methods of NamedNodeMap object
Method | Description |
---|---|
getNamedItem() | Return the node with a specific name. |
getNamedItemNS() | Return the node with a specific name and namespace. |
item() | Return the node at the specified index. |
removeNamedItem() | Remove the node with a specific name. |
removeNamedItemNS() | Remove the node with a specific name and namespace. |
setNamedItem() | Set the specified node (by name). |
setNamedItemNS() | Set the specified node (by name and namespace). |
XML DOM Document Object
Properties of Document object
Properties | Description |
---|---|
childNodes | Return the NodeList of child nodes of the document. |
doctype | Return the document type declaration associated with the document. |
documentElement | Return the root node of the document. |
documentURI | Set or return the location of the document. |
domConfig | Return the configuration used when calling normalizeDocument(). |
firstChild | Return the first child node of the document. |
implementation | Return the DOMImplementation object that handles this document. |
inputEncoding | Return the encoding used by the document (at parsing time). |
lastChild | Return the last child node of the document. |
nodeName | Return the name of the node (depending on its type). |
nodeType | Return the node type of the node. |
nodeValue | Set or return the value of the node (depending on its type). |
xmlEncoding | Return the XML encoding of the document. |
xmlStandalone | Set or return whether the document is standalone. |
xmlVersion | Set or return the XML version of the document. |
Methods of Document object
Method | Description |
---|---|
adoptNode() | Adopt a node from another document into the current document and return the adopted node. |
createAttribute() | Create an attribute node with a specified name, and return the new Attr object. |
createAttributeNS() | Create an attribute node with a specified name and namespace, and return the new Attr object. |
createCDATASection() | Create a CDATA section node. |
createComment() | Create a comment node. |
createDocumentFragment() | Create an empty DocumentFragment object and return it. |
createElement() | Creates an element node. |
createElementNS() | Creates an element node with the specified namespace. |
createEntityReference() | Creates an EntityReference object and returns this object. |
createProcessingInstruction() | Creates a ProcessingInstruction object and returns this object. |
createTextNode() | Creates a text node. |
getElementById() | Returns the element that has the id attribute with the given value. |
getElementsByTagName() | Returns a NodeList of all elements that have the specified name. |
getElementsByTagNameNS() | Returns a NodeList of all elements that have the specified name and namespace. |
importNode() | Imports a node from another document into this document. |
normalizeDocument() | |
renameNode() | Renames an element node or an attribute node. |
Properties of the DocumentType object
Each document has a DOCTYPE attribute, which is either null or a DocumentType object.
The DocumentType object provides an interface for the entities defined for the XML document.
Properties | Description |
---|---|
name | Returns the name of the DTD. |
publicId | Returns the public identifier of the DTD. |
systemId | Returns the system identifier of the external DTD. |
Methods of the DocumentImplementation object
The DOMImplementation object performs operations that are independent of any specific instance of the Document Object Model.
Method | Description |
---|---|
createDocument() | Creates a new DOM Document object of the specified document type. |
createDocumentType() | Creates an empty DocumentType node. |
getFeature() | Returns the object (if any) that implements the specified feature and version of the API. |
hasFeature() | Checks if the DOM implementation has implemented a specific feature and version. |
Properties of the ProcessingInstruction object
The ProcessingInstruction object represents a processing instruction.
Processing instructions are used as a method to retain processor-specific information within the XML document text.
Properties | Description |
---|---|
data | Sets or returns the content of the processing instruction. |
target | Returns the target of the processing instruction. |
XML DOM Element Object
Attributes of the Element object
Properties | Description |
---|---|
attributes | Returns the NamedNodeMap of the element's attributes. |
baseURI | Returns the absolute base URI of the element. |
childNodes | Returns the NodeList of the element's child nodes. |
firstChild | Returns the first child element of the element. |
lastChild | Returns the last child element of the element. |
localName | Returns the local part of the element name. |
namespaceURI | Returns the namespace URI of the element. |
nextSibling | Returns the node immediately following the element. |
nodeName | Returns the name of the node, depending on its type. |
nodeType | Return the type of the node. |
ownerDocument | Returns the root element (document object) of the node. |
parentNode | Returns the parent node of the element. |
prefix | Sets or returns the namespace prefix of the element. |
previousSibling | Returns the node immediately preceding the element. |
schemaTypeInfo | Returns the type information associated with the element. |
tagName | Returns the name of the element. |
textContent | Sets or returns the text content of the element and its descendants. |
Methods of the Element object
Method | Description |
---|---|
appendChild() | Appends a new child node to the end of the node's child node list. |
cloneNode() | Clones a node. |
compareDocumentPosition() | Compares the document position of two nodes. |
getAttribute() | Returns the value of the attribute. |
getAttributeNS() | Returns the value of the attribute (with namespace). |
getAttributeNode() | Returns an attribute node as an Attribute object. |
getAttributeNodeNS() | Returns an attribute node (with namespace) as an Attribute object. |
getElementsByTagName() | Returns a NodeList of element nodes and their child nodes that match the specified name. |
getElementsByTagNameNS() | Returns a NodeList of element nodes (with namespace) and their child nodes that match the specified name. |
getFeature()feature,version) | Returns a DOM object that implements the specialized API for the specified feature and version. |
getUserData()key) | Returns the object associated with the key on the node. The object must first be set to this node by calling setUserData with the same key. |
hasAttribute() | Returns whether the element has an attribute with the specified name. |
hasAttributeNS() | Returns whether the element has an attribute with the specified name and namespace. |
hasAttributes() | Returns whether the element has attributes. |
hasChildNodes() | Returns whether the element has child nodes. |
insertBefore() | Inserts a new child node before the existing child nodes. |
isDefaultNamespace(URI) | Returns whether the specified namespaceURI is the default. |
isEqualNode() | Checks if two nodes are equal. |
lookupNamespaceURI() | Returns the namespace URI that matches the specified prefix. |
lookupPrefix() | Returns the prefix that matches the specified namespace URI. |
normalize() |
The normalize() method removes empty text nodes and connects adjacent text nodes. Normalizes all text nodes under the element (including attributes), where only structure (such as elements, comments, processing instructions, CDATA sections, and entity references) separates text nodes. That is, there are no adjacent text nodes, nor empty text nodes. |
removeAttribute() | Removes the specified attribute. |
removeAttributeNS() | Removes the specified attribute (with namespace). |
removeAttributeNode() | Removes the specified attribute node. |
removeChild() | Removes the child node. |
replaceChild() | Replaces the child node. |
setUserData(key,data,handler) | Associates an object with the key on the element. |
setAttribute() | Adds a new attribute. |
setAttributeNS() | Adds a new attribute (with namespace). |
setAttributeNode() | Adds a new attribute node. |
setAttributeNodeNS(attrnode) | Adds a new attribute node (with namespace). |
setIdAttribute(name,isId) | If the isId attribute of the Attribute object is true, this method declares the specified attribute as a user-defined ID attribute. |
setIdAttributeNS(uri,name,isId) | If the isId attribute of the Attribute object is true, this method declares the specified attribute (with namespace) as a user-defined ID attribute. |
setIdAttributeNode(idAttr,isId) | If the isId attribute of the Attribute object is true, this method declares the specified attribute as a user-defined ID attribute. |
Attributes of the Attr object
Properties | Description |
---|---|
baseURI | Returns the absolute base URI of the attribute. |
isId | Returns true if the attribute is of type id, otherwise returns false. |
localName | Returns the local part of the attribute name. |
name | Returns the name of the attribute. |
namespaceURI | Returns the namespace URI of the attribute. |
nodeName | Return the name of the node, based on its type. |
nodeType | Return the type of the node. |
nodeValue | Set or return the value of the node, based on its type. |
ownerDocument | Return the root element (document object) of the attribute. |
ownerElement | Return the element node associated with the attribute. |
prefix | Set or return the namespace prefix of the attribute. |
schemaTypeInfo | Return the type information associated with the attribute. |
specified |
If the attribute value is set in the document, return true; If the attribute value is the default value in DTD/Schema, return false. |
textContent | Set or return the text content of the attribute. |
value | Set or return the value of the attribute. |
XML DOM Text Object
Properties of the Text object
Properties | Description |
---|---|
data | Set or return the text of the element or attribute. |
isElementContentWhitespace | Determine whether the text node contains whitespace content. |
length | Return the text length of the element or attribute. |
wholeText | Return all text adjacent to the node, concatenated in document order. |
Methods of the Text object
Method | Description |
---|---|
appendData() | Append data to the node. |
deleteData() | Delete data from the node. |
insertData() | Insert data into the node. |
replaceData() | Replace data in the node. |
replaceWholeText(text) | Replace the text of the node and all adjacent text nodes with the specified text. |
splitText() | Split a Text node into two. |
substringData() | Extract data from the node. |
XML DOM CDATASection Object
Properties of the CDATASection object
Properties | Description |
---|---|
data | Set or return the text of the node. |
length | Return the length of the CDATA section. |
Methods of the CDATASection object
Method | Description |
---|---|
appendData() | Append data to the node. |
deleteData() | Delete data from the node. |
insertData() | Insert data into the node. |
replaceData() | Replace data in the node. |
splitText() | Split a CDATA node into two nodes. |
substringData() | Extract data from the node. |
XML DOM Comment Object
Properties of the Comment object
Properties | Description |
---|---|
data | Set or return the text of the node. |
length | Return the text length of the node. |
Methods of the Comment object
Method | Description |
---|---|
appendData() | Append data to the node. |
deleteData() | Delete data from the node. |
insertData() | Insert data into the node. |
replaceData() | Replace data in the node. |
substringData() | Extract data from the node. |
XML DOM XMLHttpRequest Object
Methods of the XMLHttpRequest object
Method | Description |
---|---|
abort() | Cancel the current request. |
getAllResponseHeaders() | Return header information. |
getResponseHeader() | Return the value of the specified HTTP response header. |
open(method,url,async,uname,pswd) |
Specify the type of request, URL, whether the request should be processed asynchronously, and other optional properties of the request.
|
send(string) |
Send the request to the server. string: Used only for POST requests |
setRequestHeader() | Add a label/value pair to the headers to be sent. |
Properties of the XMLHttpRequest object
Properties | Description |
---|---|
onreadystatechange | Store the function (or function name) automatically called each time the readyState attribute changes. |
readyState |
Save the state of XMLHttpRequest. Changes from 0 to 4:
|
responseText | Return response data as a string. |
responseXML | Return response data as XML data. |
status | Return status codes (e.g., "404" indicates "Not Found", or "200" indicates "OK"). |
statusText | Return status text (e.g., "Not Found" or "OK"). |
XSD elements
XSLT element | Explanation |
---|---|
all | Specify that child elements can appear in any order, and each child element can appear zero or once. |
annotation | The annotation element is a top-level element that specifies schema annotations. |
any | Allow creators to extend the XML document through elements not specified by the schema. |
anyAttribute | Allow creators to extend the XML document through attributes not specified by the schema. |
appInfo | Specify the information that the application should use in the annotation element. |
Apply a template to the current element or its child elements. | Define an attribute. |
attributeGroup | Define a group of attributes used in the complex type definition. |
choice | Allow only one element to appear in the containing elements within the <choice> declaration. |
complexContent | Define extensions or restrictions on complex types (including mixed content or elements only). |
complexType | Define complex types. |
documentation | Define text annotations in the schema. |
element | Define an element. |
extension | Extend the existing simpleType or complexType elements. |
field | Specify an XPath expression that defines the value used to define identification constraints. |
group | Define the element group used in complex type definitions. |
import | Add multiple schemas with different target namespaces to a document. |
include | Add multiple schemas with the same target namespace to a document. |
key | Specify that the value of an attribute or element (or a set of values) must be a key within the specified range. |
keyref | Specify that the value of an attribute or element (or a set of values) corresponds to the value of a specified key or unique element. |
list | Define a simple type as a list of values of a specified data type. |
notation | Describe the format of non-XML data in an XML document. |
redefine | Redefine simple and complex types, groups, and attribute groups obtained from an external schema file. |
restriction | Define constraints on simpleType, simpleContent, or complexContent. |
schema | Define the root element of the schema. |
selector | Specify an XPath expression that selects a set of elements for identification constraints. |
sequence | Requires child elements to appear in order. Each child element can appear 0 to any number of times. |
simpleContent | Contains extensions or restrictions of complexType elements and does not contain any elements. |
simpleType | Define a simple type, specifying constraints and information about the values of attributes or elements that contain only text. |
union | Define a collection of multiple simpleType definitions. |
unique | Specify that the value of an attribute or element (or a combination of attribute or element values) must be unique within the specified range. |
Type limitations for data types in XSD
Limitation | Description |
---|---|
enumeration | Define a list of acceptable values |
fractionDigits | Define the maximum number of decimal places allowed. It must be greater than or equal to 0. |
length | Define the exact number of allowed characters or list items. It must be greater than or equal to 0. |
maxExclusive | Define the upper limit of the number. The allowed values must be less than this value. |
maxInclusive | Define the upper limit of the number. The allowed values must be less than or equal to this value. |
maxLength | Define the maximum number of allowed characters or list items. It must be greater than or equal to 0. |
minExclusive | Define the lower limit of the number. The allowed values must be greater than this value. |
minInclusive | Define the lower limit of the number. The allowed values must be greater than or equal to this value. |
minLength | Define the minimum number of characters or list items that are allowed. Must be greater than or equal to 0. |
Define the minimum number of characters or list items that are allowed. Must be greater than or equal to 0. | pattern |
Define the precise sequence of characters that are acceptable. | totalDigits |
Define the precise number of decimal places allowed for Arabic numerals. Must be greater than 0. | whiteSpace |
Define the handling of whitespace characters (newlines, carriage returns, spaces, and tabs).
XSLT element | Description |
---|---|
element | apply-imports |
Apply template rules from the imported stylesheet. | apply-templates |
Apply a template to the current element or its child elements. | Add an attribute to an element. |
attribute-set | Create a named attribute set. |
call-template | Call a specified template. |
choose | Used with <when> and <otherwise> to express multiple conditional tests. |
comment | Create a comment node in the result tree. |
copy | Create a copy of the current node (without child nodes and attributes). |
copy-of | Create a copy of the current node (with child nodes and attributes). |
decimal-format | Define the characters and symbols to be used when converting numbers to strings using the format-number() function. |
element | Create an element node in the output document. |
fallback | If the processor does not support a particular XSLT element, specify alternative code to run. |
for-each | Iterate over each node in the specified node set. |
if | Include a template and apply it only if a specified condition is met. |
import | Used to pour the content of one stylesheet into another. |
include | Include the content of one stylesheet into another. |
key | Declare a named key. |
message | Write a message to the output (for error reporting). |
namespace-alias | Replace the namespace in the stylesheet with a different namespace in the output. |
number | Determine the integer position of the current node and format the number. |
otherwise | Specify the default action of the <choose> element. |
output | Define the format of the output document. |
param | Declare a local or global parameter. |
preserve-space | Used to define elements that preserve whitespace. |
processing-instruction | Generate processing instruction nodes. |
sort | Sort the results. |
strip-space | Define elements that should remove whitespace characters. |
stylesheet | Defines the root element of the stylesheet. |
template | The rules applied when the specified node is matched. |
text | Generates text nodes through the stylesheet. |
transform | Defines the root element of the stylesheet. |
value-of | Extracts the value of the selected node. |
variable | Declares local or global variables. |
when | Specifies the action of the <choose> element. |
with-param | Specifies the value of the parameter that needs to be passed to a template. |
XSLT, XPath, and XQuery Functions
- Access
- Error and trace
- Numeric
- String
- AnyURI
- Logical
- Duration/Date/Time
- QName
- Node
- Sequence
- Context
- Built-in functions
Access functions
Name | Description |
---|---|
fn:node-name(node) | Returns the node name of the parameter node. |
fn:nilled(node) | Returns a boolean value indicating whether the parameter node is refused. |
fn:data(item.item,...) | Accepts an item sequence and returns an atomic value sequence. |
|
Returns the value of the base-uri attribute of the current node or the specified node. |
fn:document-uri(node) | Returns the value of the document-uri attribute of the specified node. |
Error and trace functions
Name | Description |
---|---|
|
Example: error(fn:QName('http://example.com/test', 'err:toohigh'), 'Error: Price is too high') Result: Returns http://example.com/test#toohigh to the external processing environment as well as the string "Error: Price is too high". |
fn:trace(value,label) | Used for debugging queries. |
Functions related to numbers
Name | Description |
---|---|
fn:number(arg) |
Returns the numeric value of the argument. The argument can be a boolean value, a string, or a node set. Example: number('100') Result: 100 |
fn:abs(num) |
Returns the absolute value of the parameter. Example: abs(3.14) Result: 3.14 Example: abs(-3.14) Result: 3.14 |
fn:ceiling(num) |
Returns the smallest integer greater than the num parameter. Example: ceiling(3.14) Result: 4 |
fn:floor(num) |
Returns the largest integer that is not greater than the num parameter. Example: floor(3.14) Result: 3 |
fn:round(num) |
Rounds the num parameter to the nearest integer. Example: round(3.14) Result: 3 |
fn:round-half-to-even() |
Example: round-half-to-even(0.5) Result: 0 Example: round-half-to-even(1.5) Result: 2 Example: round-half-to-even(2.5) Result: 2 |
Functions related to strings
Name | Description |
---|---|
fn:string(arg) |
Returns the string value of the argument. The argument can be a number, a logical value, or a node set. Example: string(314) Result: "314" |
fn:codepoints-to-string(int,int,...) |
Returns a string from a sequence of code points. Example: codepoints-to-string(84, 104, 233, 114, 232, 115, 101) Result: 'Thérèse' |
fn:string-to-codepoints(string) |
Returns a sequence of code points from a string. Example: string-to-codepoints("Thérèse") Result: 84, 104, 233, 114, 232, 115, 101 |
fn:codepoint-equal(comp1,comp2) | According to the Unicode code point collation, if the value of comp1 is equal to the value of comp2, return true. Otherwise, return false. (http://www.w3.org/2005/02/xpath-functions/collation/codepoint) |
|
If comp1 is less than comp2, return -1. If comp1 is equal to comp2, return 0. If comp1 is greater than comp2, return 1. (According to the used collation rules). Example: compare('ghi', 'ghi') Result: 0 |
fn:concat(string,string,...) |
Returns the concatenation of strings. Example: concat('XPath ','is ','FUN!') Result: 'XPath is FUN!' |
fn:string-join((string,string,...),sep) |
Uses the sep parameter as a separator to return the concatenated string of the string parameter. Example: string-join(('We', 'are', 'having', 'fun!'), ' ') Result: ' We are having fun! ' Example: string-join(('We', 'are', 'having', 'fun!')) Result: 'Wearehavingfun!' Example: string-join((), 'sep') Result: '' |
|
Returns a substring of the specified length starting from the start position. The index of the first character is 1. If the len parameter is omitted, it returns the substring from position start to the end of the string. Example: substring('Beatles',1,4) Result: 'Beat' Example: substring('Beatles',2) Result: 'eatles' |
|
Returns the length of the specified string. If no string parameter is provided, it returns the length of the string value of the current node. Example: string-length('Beatles') Result: 7 |
|
Removes leading and trailing whitespace from the specified string, replaces all internal sequences of whitespace with a single space, and then returns the result. If no string parameter is provided, it processes the current node. Example: normalize-space(' The XML ') Result: 'The XML' |
fn:normalize-unicode() | Executes Unicode normalization. |
fn:upper-case(string) |
Converts the string parameter to uppercase. Example: upper-case('The XML') Result: 'THE XML' |
fn:lower-case(string) |
Converts the string parameter to lowercase. Example: lower-case('The XML') Result: 'the xml' |
fn:translate(string1,string2,string3) |
Replaces string2 in string1 with string3. Example: translate('12:30','30','45') Result: '12:45' Example: translate('12:30','03','54') Result: '12:45' Example: translate('12:30','0123','abcd') Result: 'bc:da' |
fn:escape-uri(stringURI,esc-res) |
Example: escape-uri("http://example.com/test#car", true()) Result: "http%3A%2F%2Fexample.com%2Ftest#car" Example: escape-uri("http://example.com/test#car", false()) Result: "http://example.com/test#car" Example: escape-uri ("http://example.com/~bébé", false()) Result: "http://example.com/~b%C3%A9b%C3%A9" |
fn:contains(string1,string2) |
If string1 contains string2, returns true, otherwise returns false. Example: contains('XML','XM') Result: true |
fn:starts-with(string1,string2) |
If string1 starts with string2, returns true, otherwise returns false. Example: starts-with('XML','X') Result: true |
fn:ends-with(string1,string2) |
If string1 ends with string2, returns true, otherwise returns false. Example: ends-with('XML','X') Result: false |
fn:substring-before(string1,string2) |
Returns the substring before the occurrence of string2 in string1. Example: substring-before('12/10','/') Result: '12' |
fn:substring-after(string1,string2) |
Returns the substring after the occurrence of string2 in string1. Example: substring-after('12/10','/') Result: '10' |
fn:matches(string,pattern) |
Returns true if the string parameter matches the specified pattern, otherwise returns false. Example: matches("Merano", "ran") Result: true |
fn:replace(string,pattern,replace) |
Replaces the specified pattern with the replace parameter and returns the result. Example: replace("Bella Italia", "l", "*") Result: 'Be**a Ita*ia' Example: replace("Bella Italia", "l", "") Result: 'Bea Itaia' |
fn:tokenize(string,pattern) |
Example: tokenize("XPath is fun", "\s+") Result: ("XPath", "is", "fun") |
Functions for anyURI
Name | Description |
---|---|
fn:resolve-uri(relative,base) |
Functions related to boolean values
Name | Description |
---|---|
fn:boolean(arg) | Returns the boolean value of a number, string, or node set. |
fn:not(arg) |
First, restore the parameter to a boolean value using the boolean() function. Returns true if the boolean value is false, otherwise returns true. Example: not(true()) Result: false |
fn:true() |
Returns the boolean value true. Example: true() Result: true |
fn:false() |
Returns the boolean value false. Example: false() Result: false |
Functions related to duration, date, and time
Function to extract components of date, time, and duration
Name | Description |
---|---|
fn:dateTime(date,time) | Converts the parameter to a date and time. |
fn:years-from-duration(datetimedur) | Returns the integer part of the year parameter value, represented in standard lexical notation. |
fn:months-from-duration(datetimedur) | Returns the integer part of the month parameter value, represented in standard lexical notation. |
fn:days-from-duration(datetimedur) | Returns the integer part of the day parameter value, represented in standard lexical notation. |
fn:hours-from-duration(datetimedur) | Returns the integer representing the hours part of the parameter value, expressed in standard lexical notation. |
fn:minutes-from-duration(datetimedur) | Returns the integer representing the minutes part of the parameter value, expressed in standard lexical notation. |
fn:seconds-from-duration(datetimedur) | Returns the decimal number representing the minutes part of the parameter value, expressed in standard lexical notation. |
fn:year-from-dateTime(datetime) |
Returns the integer representing the year part of the local value of the parameter. Example: year-from-dateTime(xs:dateTime("2005-01-10T12:30-04:10")) Result: 2005 |
fn:month-from-dateTime(datetime) |
Returns the integer representing the month part of the local value of the parameter. Example: month-from-dateTime(xs:dateTime("2005-01-10T12:30-04:10")) Result: 01 |
fn:day-from-dateTime(datetime) |
Returns the integer representing the day part of the local value of the parameter. Example: day-from-dateTime(xs:dateTime("2005-01-10T12:30-04:10")) Result: 10 |
fn:hours-from-dateTime(datetime) |
Returns the integer representing the hours part of the local value of the parameter. Example: hours-from-dateTime(xs:dateTime("2005-01-10T12:30-04:10")) Result: 12 |
fn:minutes-from-dateTime(datetime) |
Returns the integer representing the minutes part of the local value of the parameter. Example: minutes-from-dateTime(xs:dateTime("2005-01-10T12:30-04:10")) Result: 30 |
fn:seconds-from-dateTime(datetime) |
Returns the decimal number representing the seconds part of the local value of the parameter. Example: seconds-from-dateTime(xs:dateTime("2005-01-10T12:30:00-04:10")) Result: 0 |
fn:timezone-from-dateTime(datetime) | Returns the time zone part of the parameter, if it exists. |
fn:year-from-date(date) |
Returns the local value of the parameter as an integer representing the year. Example: year-from-date(xs:date("2005-04-23")) Result: 2005 |
fn:month-from-date(date) |
Returns the integer representing the month of the local value of the parameter. Example: month-from-date(xs:date("2005-04-23")) Result: 4 |
fn:day-from-date(date) |
Returns the integer representing the day of the local value of the parameter. Example: day-from-date(xs:date("2005-04-23")) Result: 23 |
fn:timezone-from-date(date) | Returns the time zone part of the parameter, if it exists. |
fn:hours-from-time(time) |
Returns the integer representing the hours part of the local value of the parameter. Example: hours-from-time(xs:time("10:22:00")) Result: 10 |
fn:minutes-from-time(time) |
Returns the integer representing the minutes part of the local value of the parameter. Example: minutes-from-time(xs:time("10:22:00")) Result: 22 |
fn:seconds-from-time(time) |
Returns the integer representing the seconds part of the local value of the parameter. Example: seconds-from-time(xs:time("10:22:00")) Result: 0 |
fn:timezone-from-time(time) | Returns the time zone part of the parameter, if it exists. |
fn:adjust-dateTime-to-timezone(datetime,timezone) |
If the timezone parameter is empty, return the dateTime without the time zone. Otherwise, return the dateTime with the time zone. |
fn:adjust-date-to-timezone(date,timezone) |
If the timezone parameter is empty, return the date without the time zone. Otherwise, return the date with the time zone. |
fn:adjust-time-to-timezone(time,timezone) |
If the timezone parameter is empty, return the time without the time zone. Otherwise, return the time with the time zone. |
Functions related to QNames
Name | Description |
---|---|
fn:QName() | |
fn:local-name-from-QName() | |
fn:namespace-uri-from-QName() | |
fn:namespace-uri-for-prefix() | |
fn:in-scope-prefixes() | |
fn:resolve-QName() |
Functions about nodes
Name | Description |
---|---|
|
Returns the name of the current node or the first node in the specified node set. |
|
Returns the name of the current node or the first node in the specified node set - without the namespace prefix. |
|
Returns the namespace URI of the current node or the first node in the specified node set. |
fn:lang(lang) |
If the language of the current node matches the specified language, it returns true. Example: Lang("en") is true for <p xml:lang="en">...</p> Example: Lang("de") is false for <p xml:lang="en">...</p> |
|
Returns the root node of the node tree belonging to the current node or the specified node. It is usually the document node. |
Functions related to sequences
General function
Name | Description |
---|---|
fn:index-of((item,item,...),searchitem) |
Returns the position in the item sequence that is equal to the searchitem parameter. Example: index-of ((15, 40, 25, 40, 10), 40) Result: (2, 4) Example: index-of (("a", "dog", "and", "a", "duck"), "a") Result (1, 4) Example: index-of ((15, 40, 25, 40, 10), 18) Result: () |
fn:remove((item,item,...),position) |
Returns a new sequence constructed by the item parameter - while deleting the item at the specified position. Example: remove(("ab", "cd", "ef"), 0) Result: ("ab", "cd", "ef") Example: remove(("ab", "cd", "ef"), 1) Result: ("cd", "ef") Example: remove(("ab", "cd", "ef"), 4) Result: ("ab", "cd", "ef") |
fn:empty(item,item,...) |
If the parameter value is an empty sequence, it returns true, otherwise it returns false. Example: empty(remove(("ab", "cd"), 1)) Result: false |
fn:exists(item,item,...) |
Returns true if the parameter value is not an empty sequence, otherwise returns false. Example: exists(remove(("ab"), 1)) Result: false |
fn:distinct-values((item,item,...),collation) |
Returns unique different values. Example: distinct-values((1, 2, 3, 1, 2)) Result: (1, 2, 3) |
fn:insert-before((item,item,...),pos,inserts) |
Returns a new sequence constructed by the item parameter - inserting the value of the inserts parameter at the position specified by the pos parameter. Example: insert-before(("ab", "cd"), 0, "gh") Result: ("gh", "ab", "cd") Example: insert-before(("ab", "cd"), 1, "gh") Result: ("gh", "ab", "cd") Example: insert-before(("ab", "cd"), 2, "gh") Result: ("ab", "gh", "cd") Example: insert-before(("ab", "cd"), 5, "gh") Result: ("ab", "cd", "gh") |
fn:reverse((item,item,...)) |
Returns the reversed order of the specified items. Example: reverse(("ab", "cd", "ef")) Result: ("ef", "cd", "ab") Example: reverse(("ab")) Result: ("ab") |
fn:subsequence((item,item,...),start,len) |
Returns the item sequence starting from the position specified by the start parameter, with a length specified by the len parameter. The position of the first item is 1. Example: subsequence(($item1, $item2, $item3,...), 3) Result: ($item3, ...) Example: subsequence(($item1, $item2, $item3, ...), 2, 2) Result: ($item2, $item3) |
fn:unordered((item,item,...)) | Returns the items in the order determined by the implementation. |
Function to test the sequence capacity
Name | Description |
---|---|
fn:zero-or-one(item,item,...) | Returns the parameter if it contains zero or one item, otherwise generates an error. |
fn:one-or-more(item,item,...) | Returns the parameter if it contains one or more items, otherwise generates an error. |
fn:exactly-one(item,item,...) | Returns the parameter if it contains one item, otherwise generates an error. |
Equals, Union, Intersection and Except
Name | Description |
---|---|
fn:deep-equal(param1,param2,collation) | Returns true if param1 and param2 are equal to each other (deep-equal), otherwise returns false. |
Aggregate Functions
Name | Description |
---|---|
fn:count((item,item,...)) | Returns the number of nodes. |
fn:avg((arg,arg,...)) |
Returns the average of the values of the arguments. Example: avg((1,2,3)) Result: 2 |
fn:max((arg,arg,...)) |
Returns the argument that is greater than the other arguments. Example: max((1,2,3)) Result: 3 Example: max(('a', 'k')) Result: 'k' |
fn:min((arg,arg,...)) |
Returns the argument that is less than the other arguments. Example: min((1,2,3)) Result: 1 Example: min(('a', 'k')) Result: 'a' |
fn:sum(arg,arg,...) | Returns the sum of the numerical values of each node in the specified node set. |
Sequence Generation Functions
Name | Description |
---|---|
fn:id((string,string,...),node) | Returns a sequence of element nodes whose ID value equals one or more values specified in the string parameter. |
fn:idref((string,string,...),node) | Returns a sequence of element or attribute nodes whose IDREF value equals one or more values specified in the string parameter. |
fn:doc(URI) | |
fn:doc-available(URI) | Returns true if the doc() function returns a document node, otherwise returns false. |
|
Context Functions
Name | Description |
---|---|
fn:position() |
Returns the index position of the current node being processed. Example: //book[position()<=3] Result: Select the first three 'book' elements |
fn:last() |
Returns the number of items in the list of nodes being processed. Example: //book[last()] Result: Select the last book element |
fn:current-dateTime() | Returns the current dateTime (with timezone). |
fn:current-date() | Returns the current date (with timezone). |
fn:current-time() | Returns the current time (with timezone). |
fn:implicit-timezone() | Returns the value of the implicit timezone. |
fn:default-collation() | Returns the value of the default collation. |
fn:static-base-uri() | Returns the value of base-uri. |
XSLT Functions
In addition, there are the following built-in XSLT functions:
Name | Description |
---|---|
current() | Returns a node set containing the current node as its only member. |
document() | Used to access nodes in an external XML document. |
element-available() | Determines whether the XSLT processor supports the specified element. |
format-number() | Converts a number to a string. |
function-available() | Determines whether the XSLT processor supports the specified function. |
generate-id() | Returns a string value that uniquely identifies the specified node. |
key() | Retrieves elements previously marked with an <xsl:key> statement. |
node-set | Converts a tree to a node set. The resulting node set always contains a single node and is the root of the tree. |
system-property() | Returns the value of the system property. |
unparsed-entity-uri() | Returns the URI of the unparsed entity. |
Other XML DOM Objects
- DOM CharacterData
- DOM CSS2Properties
- DOM CSSRule
- DOM CSSStyleRule
- DOM CSSStyleSheet
- DOM DocumentType
- DOM DOMException
- DOM Implementation
- DOM DOMParser
- DOM Event
- DOM HTMLCollection
- DOM HTMLDocument
- DOM HTMLElement
- DOM ProcessingInstr
- DOM Range
- DOM RangeException
- DOM XMLSerializer
- DOM XPathExpression
- DOM XPathResult
- DOM XSLTProcessor
- Previous Page XSD Miscellaneous
- Next Page DOM Node Types