Files
release11-tools/Frontend/tools/xpath.html
2023-03-29 11:03:34 +02:00

1353 lines
78 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<!-- <link rel="stylesheet" href="../common.css"> -->
<!-- <link rel="stylesheet" href="styles.css"> -->
<link rel="stylesheet" href="../assets/css/tools/r11form.css">
<script src="../assets/scripts/tools/scripts.js"> </script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8" />
</head>
<body onload="init();">
<div class="container">
<div id="tool" class="tool rwd-expandable">
<div class="tool-context">
<div class="headline">
<h1>Online XPath tester</h1>
</div>
<div class="display-space-between">
<div>
<label for="processors">Select XPath processor:</label>
<select name="processors" id="processors">
<option value="saxon">Saxon</option>
<option value="xalan">Xalan</option>
<option value="libxml">libXML</option>
</select><br>
<label for="versions">XPath version:</label>
<select name="versions" id="versions">
<option class="hideable libxml xalan"value="1.0">1.0</option>
<option class="hideable saxon" value="2.0">2.0</option>
<option class="hideable saxon" value="3.0">3.0</option>
<option class="hideable saxon" value="3.1">3.1</option>
</select>
</div>
<div>
<button class="action-button active" id="clearXMLButton" style="padding: 3px 10px;"
onclick="clearDataField()">Clear</button>
<button class="action-button active" id="prettyXMLButton" style="padding: 3px 10px;"
onclick="performFormatRequest('prettify', true, 'xmlArea', 'xmlArea')">Format XML</button>
<button class="action-button active" id="defaultXMLButton" style="padding: 3px 10px;"
onclick="fillDefaultXML(this)">Insert default XML</button>
</div>
</div>
<br>
<label for="xmlArea"><b>Insert your XML:</b></label>
<textarea id="xmlArea" name="xmlArea" rows="15"
class="textarea-300 bordered-field vertically-resizeable max-width"
onblur="setDefaultContent(this, 'Insert XML here');"
onfocus="clearDefaultContent(this, 'Insert XML here');"></textarea>
<br><br>
<label for="transformArea"><b>Insert your XPath:</b></label>
<textarea id="transformArea" name="transformArea"
class="bordered-field vertically-resizeable max-width" rows="4"
onblur="setDefaultContent(this, 'Insert XPath expression here');"
onfocus="clearDefaultContent(this, 'Insert XPath expression here');"></textarea>
<br>
<button id="requestButton" class="max-width block-label action-button active"
onclick="performRequest('xpath', false, true)">Execute XPath
expression</button>
<br><br>
<label for="resultArea"><b>Transform result:<span id="procinfo"></span></b></label>
<textarea disabled id="resultArea" name="resultArea"
class="textarea-300 bordered-field vertically-resizeable max-width" style="margin-bottom: 50px;" rows="10" cols="100"></textarea>
</div>
</div>
<div class="tooltip tooltip-window rwd-hideable">
<h2>What is XPath?</h2>
<p>XPath is a query language used for selecting nodes from XML and processing them.<br>
It may perform operations on strings, numbers and boolean values.<br></p>
<span id="collapsible-lists">
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">XPath 1.0 vs 2.0 vs 3.0 vs
3.1</button>
</span>
<div class="content">
<p><b>XPath 2.0 introduced many new features XQuery-cośtam:</b><br>
- Added support for all XML simple types<br>
- Many new functions (tripled instruction count)<br>
- All expressions evaluate to sequence<br>
- Introduces conditional expressions and for-loops<br>
</p>
<p><b>XPath 3.0</b><br>
- Dynamic function calls (function may be called without being referenced by name (find
function in collection and call)<br>
- Inline functions<br>
- Namespace literals - Namespace may be embedded into function name<br>
- Support for union types - collections containing elements of different types<br>
- Mapping operator - '!' performs evaluation for each element in sequence and
concatenates results<br>
- Introduced maps <br>
</p>
<p><b>XPath 3.1</b><br>
- New operator for function chaining '=>' <br>
- Introduced maps that store data in pair 'key:value' - 'map{ key : value, key : value
}'<br>
- Introduced arrays - they differ from sequences in that they can be nested 'array{1, 5, 7,
(10 to 20)}'<br>
</p>
</div>
</div>
<h2><span id="tooltipFunctionInfo">XPath 1.0 & 2.0 functions</span></h2>
<!-- Cut here -->
<span name="collapse10">
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Node-Set</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:position()</code></a>
<div class="content">
Returns the position of the current context node <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:count(node-set)</code></a>
<div class="content">
Returns the number of nodes in the node-set <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node-set</td>
<td>Node-set to count nodes in</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>count(//b:book)</td>
<td>5</td>
</tr>
<tr>
<td>count(//person[@id>5])</td>
<td>17</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:id(object)</code></a>
<div class="content">
Returns the element specified by it's unique id, requires DTD <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:local-name(node-set)</code></a>
<div class="content">
Returns the local-name for the first node in the node-set <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node-set</td>
<td>Extract first node and return its local name</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>local-name(//b:books)</td>
<td>b:book</td>
</tr>
<tr>
<td>local-name(//b:book)</td>
<td>b:title</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:local-name()</code></a>
<div class="content">
Returns the local-name for the context node <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:namespace-uri(node-set)</code></a>
<div class="content">
Returns the namespace-uri for the first node in the node-set <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node-set</td>
<td>Extract first node and return the namespace URI</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>namespace-uri(//b:book)</td>
<td>http://www.book.com</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:namespace-uri()</code></a>
<div class="content">
Returns the namespace-uri for the context node <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:name(node-set)</code></a>
<div class="content">
Returns the name for the first node in the node-set <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node-set</td>
<td>Extract first node and return QName</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>name(//b:books/*)</td>
<td>b:book</td>
</tr>
<tr>
<td>name(//b:book/*)</td>
<td>b:title</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:name()</code></a>
<div class="content">
Returns the name for the context node <br>
<b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>current context node</td>
<td>Extract first node and return QName</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Boolean</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:boolean(object)</code></a>
<div class="content">
The boolean function converts its argument to a boolean as follows:
<ul>
<li>a number is true if and only if it is neither positive or negative zero nor NaN</li>
<li>a node-set is true if and only if it is non-empty</li>
<li>a string is true if and only if its length is non-zero</li>
<li>an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type</li>
</ul>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>object</td>
<td>The object to convert to a boolean</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>boolean("Release11")</td>
<td>true</td>
</tr>
<tr>
<td>boolean("")</td>
<td>false</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Boolean-Functions" class="hyperlink" target="_blank">Boolean-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:not()</code></a>
<div class="content">
The not function returns true if its argument is false, and false otherwise. <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#function-not" class="hyperlink" target="_blank">Boolean-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:true()</code></a>
<div class="content">
The true function returns true. <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Boolean-Functions" class="hyperlink" target="_blank">Boolean-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:false()</code></a>
<div class="content">
The true function returns false. <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Boolean-Functions" class="hyperlink" target="_blank">Boolean-Functions</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:lang(string)</code></a>
<div class="content">
The lang function returns true or false depending on whether the language of the context node as specified by xml:lang attributes is the same as or is a sublanguage of the language specified by the argument string. The language of the context node is determined by the value of the xml:lang attribute on the context node, or, if the context node has no xml:lang attribute, by the value of the xml:lang attribute on the nearest ancestor of the context node that has an xml:lang attribute. If there is no such attribute, then lang returns false. If there is such an attribute, then lang returns true if the attribute value is equal to the argument ignoring case, or if there is some suffix starting with - such that the attribute value is equal to the argument ignoring that suffix of the attribute value and ignoring case. <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>string</td>
<td>Language that will be looked for in context node</td>
</tr>
</table><b>Examples: </b> Look W3C documentation<br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Boolean-Functions" class="hyperlink" target="_blank">Boolean-Functions</code></a>
</div>
</div>
</div>
</span>
<span name="collapse20">
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Node-Set</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:name()</code></a>
<div class="content">
Returns the name of a node, as an xs:string that is either the zero-length string, or has the lexical form of an xs:QName.<br>
If the argument is omitted, it defaults to the context item (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.<br>
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.<br>
If the argument is supplied and is the empty sequence, the function returns the zero-length string.<br>
If the target node has no name (that is, if it is a document node, a comment, a text node, or a namespace binding having no name), the function returns the zero-length string.<br>
Otherwise, the value returned is fn:string(fn:node-name($arg)).<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node?</td>
<td>Node to display name.</td>
</tr>
</table>
<b>Return type:</b> xs:string<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>name(/l:library)</td>
<td>l:library</td>
</tr>
</table><br>
<a href=https://www.w3.org/TR/xquery-operators/#func-name" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:local-name()</code></a>
<div class="content">
Returns the local part of the name of $arg as an xs:string that will either be the zero-length string or will have the lexical form of an xs:NCName.<br>
If the argument is omitted, it defaults to the context item (.). The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.<br>
The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.<br>
If the argument is supplied and is the empty sequence, the function returns the zero-length string.<br>
If the target node has no name (that is, if it is a document node, a comment, or a text node), the function returns the zero-length string.<br>
Otherwise, the value returned will be the local part of the expanded-QName of the target node (as determined by the dm:node-name accessor in Section 5.11 node-name Accessor). This will be an xs:string whose lexical form is an xs:NCName.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node?</td>
<td>Node to display local-name.</td>
</tr>
</table>
<b>Return type:</b> xs:string<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>name(/l:library)</td>
<td>library</td>
</tr>
</table><br>
<a href=https://www.w3.org/TR/xquery-operators/#func-local-name" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:nilled()</code></a>
<div class="content">
Returns an xs:boolean indicating whether the argument node is "nilled". If the argument is not an element node, returns the empty sequence. If the argument is the empty sequence, returns the empty sequence.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node?</td>
<td>Node to test.</td>
</tr>
</table>
<b>Return type:</b> xs:boolean?<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>nilled(/l:library)</td>
<td>false</td>
</tr>
</table><br>
<a href=https://www.w3.org/TR/xquery-operators/#func-nilled" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:base-uri()</code></a>
<div class="content">
Returns the value of the base-uri URI property for $arg as defined by the accessor function dm:base-uri() for that kind of node in Section 5.2 base-uri AccessorDM. If $arg is not specified, the behavior is identical to calling the function with the context item (.) as argument. The following errors may be raised: if the context item is undefined [err:XPDY0002]XP; if the context item is not a node [err:XPTY0004]XP.<br>
If $arg is the empty sequence, the empty sequence is returned.<br>
Document, element and processing-instruction nodes have a base-uri property which may be empty. The base-uri property of all other node types is the empty sequence. The value of the base-uri property is returned if it exists and is not empty. Otherwise, if the node has a parent, the value of dm:base-uri() applied to its parent is returned, recursively. If the node does not have a parent, or if the recursive ascent up the ancestor chain encounters a node whose base-uri property is empty and it does not have a parent, the empty sequence is returned.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node?</td>
<td>Node to find base URI of.</td>
</tr>
</table>
<b>Return type:</b> xs:anyURI?<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>base-uri(/l:library/l:libraryName)</td>
<td>&lt;empty sequence&gt;</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-base-uri" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:document-uri()</code></a>
<div class="content">
Returns the value of the document-uri property for $arg as defined by the dm:document-uri accessor function defined in Section 6.1.2 AccessorsDM.<br>
If $arg is the empty sequence, the empty sequence is returned.<br>
Returns the empty sequence if the node is not a document node. Otherwise, returns the value of the dm:document-uri accessor of the document node.<br>
In the case of a document node $D returned by the fn:doc function, or a document node at the root of a tree containing a node returned by the fn:collection function, it will always be true that either fn:document-uri($D) returns the empty sequence, or that the following expression is true: fn:doc(fn:document-uri($D)) is $D. It is implementation-defined whether this guarantee also holds for document nodes obtained by other means, for example a document node passed as the initial context node of a query or transformation.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>node?</td>
<td>Node which document-uri value needs to be returned.</td>
</tr>
</table>
<b>Return type:</b> xs:anyURI?<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>document-uri(/l:library/l:libraryName)</td>
<td>&lt;empty sequence&gt;</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-document-uri" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:last()</code></a>
<div class="content">
Returns the position of the last node in the context list <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/xquery-operators/#func-local-name" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Boolean</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:boolean(object)</code></a>
<div class="content">
The boolean function converts its argument to a boolean as follows:
<ul>
<li>a number is true if and only if it is neither positive or negative zero nor NaN</li>
<li>a node-set is true if and only if it is non-empty</li>
<li>a string is true if and only if its length is non-zero</li>
<li>an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type</li>
</ul>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>object</td>
<td>The object to convert to a boolean</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>boolean("Release11")</td>
<td>true</td>
</tr>
<tr>
<td>boolean("")</td>
<td>false</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Boolean-Functions" class="hyperlink" target="_blank">Boolean-Functions</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">String</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:string(object)</code></a>
<div class="content">
Returns the value of $arg represented as a xs:string. If no argument is supplied, the context item (.) is used as the default argument. The behavior of the function if the argument is omitted is exactly the same as if the context item had been passed as the argument.<br>
If the context item is undefined, error [err:XPDY0002]XP is raised.<br>
If $arg is the empty sequence, the zero-length string is returned.<br>
If $arg is a node, the function returns the string-value of the node, as obtained using the dm:string-value accessor defined in the Section 5.13 string-value AccessorDM.<br>
If $arg is an atomic value, then the function returns the same string as is returned by the expression " $arg cast as xs:string " (see 17 Casting).<br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>string</td>
<td>The object to convert to a string</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>string((1&lt;0))</td>
<td>false</td>
</tr>
<tr>
<td>string(.11)</td>
<td>0.11</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-string" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Numeric</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:number()</code></a>
<div class="content">
Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double<br>
Calling the zero-argument version of the function is defined to give the same result as calling the single-argument version with the context item (.). That is, fn:number() is equivalent to fn:number(.).<br>
If $arg is the empty sequence or if $arg or the context item cannot be converted to an xs:double, the xs:double value NaN is returned. If the context item is undefined an error is raised: [err:XPDY0002]XP.<br>
If $arg is the empty sequence, NaN is returned. Otherwise, $arg, or the context item after atomization, is converted to an xs:double following the rules of 17.1.3.2 Casting to xs:double. If the conversion to xs:double fails, the xs:double value NaN is returned.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>xs:anyAtomicType?</td>
<td>Value to convert to number</td>
</tr>
</table>
<b>Return type:</b> xs:double<br><br>
<a href=https://www.w3.org/TR/xquery-operators/#func-number" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span name="collapse20">
<button class="section-button collapseTrigger" style="border: none">Collections</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:data()</code></a>
<div class="content">
fn:data takes a sequence of items and returns a sequence of atomic values.<br>
The result of fn:data is the sequence of atomic values produced by applying the following rules to each item in $arg:<br>
<ul>
<li>If the item is an atomic value, it is returned.</li>
<li>
If the item is a node:
<ul>
<li>If the node does not have a typed value an error is raised [err:FOTY0012].</li>
<li>Otherwise, fn:data() returns the typed value of the node as defined by the accessor function dm:typed-value in Section 5.15 typed-value AccessorDM.</li>
</ul>
</li>
</ul>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>item*</td>
<td>Items to convert.</td>
</tr>
</table>
<b>Return type:</b> xs:anyAtomicType*<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>data(/l:library/l:readerList/p:person[1])</td>
<td>7321<br>Adam<br>Choke</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-data" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span name="collapse20">
<button class="section-button collapseTrigger" style="border: none">Date / Time</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:adjust-date-to-timezone(date,timezone)</code></a>
<div class="content">
If the timezone argument is empty, it returns a date without a timezone. Otherwise,
it returns a date with a timezone <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>date</td>
<td>date to be adjusted</td>
</tr>
<tr>
<td>timezone</td>
<td>timezone to be imposed into date</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>adjust-date-to-timezone(xs:date('2011-11-15'),
xs:dayTimeDuration("PT10H"))</td>
<td>2011-11-15+10:00</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/xpath-functions/#func-adjust-date-to-timezone" class="hyperlink" target="_blank">#func-adjust-date-to-timezone</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span name="collapse20">
<button class="section-button collapseTrigger" style="border: none">Error</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:error()</code></a>
<div class="content">
The fn:error function is a general function that may be invoked as above but may also be invoked from [XQuery 1.0: An XML Query Language] or [XML Path Language (XPath) 2.0] applications with, for example, an xs:QName argument.
<br>
<a href="https://www.w3.org/TR/xquery-operators/#func-error" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:trace()</code></a>
<div class="content">
Provides an execution trace intended to be used in debugging queries.<br>
The input $value is returned, unchanged, as the result of the function. In addition, the inputs $value, converted to an xs:string, and $label may be directed to a trace data set. The destination of the trace output is ·implementation-defined·. The format of the trace output is ·implementation dependent·. The ordering of output from invocations of the fn:trace() function is ·implementation dependent·.<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>item*</td>
<td>$value</td>
</tr>
<tr>
<td>xs:string</td>
<td>$label</td>
</tr>
</table>
<b>Return type:</b> item<br><br>
<br>
<a href="https://www.w3.org/TR/xquery-operators/#func-trace" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span name="collapse20">
<button class="section-button collapseTrigger" style="border: none">Misc</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:nilled(node)</code></a>
<div class="content">
Returns a Boolean value indicating whether the argument node is nilled <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/xpath-functions/#func-nilled" class="hyperlink" target="_blank">#func-nilled</code></a>
</div>
</div>
</div>
</span>
<span name="collapse30">
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Node-Set</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:last()</code></a>
<div class="content">
Returns the position of the last node in the context list <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Node-Set-Functions" class="hyperlink" target="_blank">Node-Set-Functions</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Boolean</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:boolean(object)</code></a>
<div class="content">
The boolean function converts its argument to a boolean as follows:
<ul>
<li>a number is true if and only if it is neither positive or negative zero nor NaN</li>
<li>a node-set is true if and only if it is non-empty</li>
<li>a string is true if and only if its length is non-zero</li>
<li>an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type</li>
</ul>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>object</td>
<td>The object to convert to a boolean</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>boolean("Release11")</td>
<td>true</td>
</tr>
<tr>
<td>boolean("")</td>
<td>false</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Boolean-Functions" class="hyperlink" target="_blank">Boolean-Functions</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">String</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:string(object)</code></a>
<div class="content">
Returns the string representation of the object argument <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>string</td>
<td>The object to convert to a string</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>string((1&lt;0))</td>
<td>false</td>
</tr>
<tr>
<td>string(.11)</td>
<td>0.11</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-String-Functions" class="hyperlink" target="_blank">String-Functions</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Numeric</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:number(object)</code></a>
<div class="content">
The number function converts its argument to a number as follows:
<ul>
<li>a string that consists of optional whitespace followed by an optional minus sign followed by a Number followed by whitespace is converted to the IEEE 754 number that is nearest (according to the IEEE 754 round-to-nearest rule) to the mathematical value represented by the string; any other string is converted to NaN</li>
<li>boolean true is converted to 1; boolean false is converted to 0</li>
<li>a node-set is first converted to a string as if by a call to the string function and then converted in the same way as a string argument</li>
<li>an object of a type other than the four basic types is converted to a number in a way that is dependent on that type</li>
</ul>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>object</td>
<td>The object to convert to a number</td>
</tr>
</table>
<b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>boolean("Release11")</td>
<td>true</td>
</tr>
<tr>
<td>boolean("")</td>
<td>false</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Number-Functions" class="hyperlink" target="_blank">Numeric-Functions</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Date / Time</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:adjust-date-to-timezone(date,timezone)</code></a>
<div class="content">
If the timezone argument is empty, it returns a date without a timezone. Otherwise,
it returns a date with a timezone <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>date</td>
<td>date to be adjusted</td>
</tr>
<tr>
<td>timezone</td>
<td>timezone to be imposed into date</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>adjust-date-to-timezone(xs:date('2011-11-15'),
xs:dayTimeDuration("PT10H"))</td>
<td>2011-11-15+10:00</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/xpath-functions/#func-adjust-date-to-timezone" class="hyperlink" target="_blank">#func-adjust-date-to-timezone</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Error</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:error()</code></a>
<div class="content">
https://www.w3.org/TR/xpath-functions/#func-error <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/xpath-functions/#func-error" class="hyperlink" target="_blank">#func-error</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Misc</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:nilled(node)</code></a>
<div class="content">
Returns a Boolean value indicating whether the argument node is nilled <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/xpath-functions/#func-nilled" class="hyperlink" target="_blank">#func-nilled</code></a>
</div>
</div>
</div>
<div class="collapsible">
<span>
<button class="section-button collapseTrigger" style="border: none">Loop /
Conditional</button>
</span>
<div class="content">
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:for-each(sequence*, function)</code></a>
<div class="content">
Applies function item to every element in sequence <br>
<br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/xpath-functions-30/#func-for-each" class="hyperlink" target="_blank">#func-for-each</code></a>
</div>
</div>
</div>
</span>
</div>
<!-- Cut here -->
</span>
</div>
</div>
<script>
function processVersionSelector() {
var processor = getProcessor();
var hideableOptions = document.getElementsByClassName("hideable");
for (let i = 0; i < hideableOptions.length; i++) {
hideableOptions[i].style = "display: none;";
}
if (processor == "xalan" || processor == "libxml") {
var xalanOptions = document.getElementsByClassName("xalan");
for (let i = 0; i < xalanOptions.length; i++) {
xalanOptions[i].style = "";
}
document.getElementById("versions").selectedIndex = 0;
}
else {
var saxonOptions = document.getElementsByClassName("saxon");
for (let i = 0; i < saxonOptions.length; i++) {
saxonOptions[i].style = "";
}
document.getElementById("versions").selectedIndex = 3;
}
processTooltip();
}
function processTooltip() {
var filter = "collapse" + getVersion();
var collList;
if (filter == "collapse3.0") {
document.getElementById("tooltipFunctionInfo").innerText = "XPath 3.0 functions";
hideList(document.getElementsByName("collapse10"));
hideList(document.getElementsByName("collapse20"));
showList(document.getElementsByName("collapse30"));
hideList(document.getElementsByName("collapse31"));
} else if (filter == "collapse3.1") {
document.getElementById("tooltipFunctionInfo").innerText = "XPath 3.1 functions";
hideList(document.getElementsByName("collapse10"));
hideList(document.getElementsByName("collapse20"));
hideList(document.getElementsByName("collapse30"));
showList(document.getElementsByName("collapse31"));
} else if (filter == "collapse2.0"){
document.getElementById("tooltipFunctionInfo").innerText = "XPath 2.0 functions";
hideList(document.getElementsByName("collapse10"));
showList(document.getElementsByName("collapse20"));
hideList(document.getElementsByName("collapse30"));
hideList(document.getElementsByName("collapse31"));
} else {
document.getElementById("tooltipFunctionInfo").innerText = "XPath 1.0 functions";
showList(document.getElementsByName("collapse10"));
hideList(document.getElementsByName("collapse20"));
hideList(document.getElementsByName("collapse30"));
hideList(document.getElementsByName("collapse31"));
}
}
var triggerList = document.getElementsByClassName("collapseTrigger");
for (i = 0; i < triggerList.length; i++) {
triggerList[i].addEventListener("click", function () {
var collapsible = this.parentElement;
if (this.tagName == "A") {
var collapsibleData = this.nextElementSibling;
} else {
var collapsibleData = this.parentElement.nextElementSibling;
}
if (collapsibleData.style.maxHeight > "0px") {
collapsibleData.style.maxHeight = "0px";
this.classList.toggle("active", false);
if (!this.classList.contains("collapsibleMini")) {
collapsible.classList.toggle("active", false);
}
var subLists1 = collapsibleData.getElementsByClassName("content");
var subLists2 = collapsibleData.getElementsByClassName("active");
for (j = 0; j < subLists1.length; j++) {
subLists1[j].style.maxHeight = "0px";
}
for (j = 0; j < subLists2.length; j++) {
subLists2[j].classList.toggle("active", false);
}
} else {
collapsibleData.style.maxHeight = (collapsibleData.scrollHeight) + "px";
this.classList.toggle("active", true);
if (!this.classList.contains("collapsibleMini")) {
collapsible.classList.toggle("active", true);
} else {
var parentContent = this.closest(".content");
parentContent.style.maxHeight = (parentContent.scrollHeight + collapsibleData.scrollHeight) + "px";
}
}
});
}
function init() {
//Handle clicks in whole form and set info in tooltip
setDefaultContent(document.getElementById("xmlArea"), 'Insert XML here');
setDefaultContent(document.getElementById("transformArea"), 'Insert XPath expression here');
processVersionSelector();
processTooltip();
tool.addEventListener('change', event => {
//Check if script was called from textarea or selector
var targetID = event.target.getAttribute('id');
if (targetID == "processors") {
processVersionSelector();
processTooltip();
}
else if (targetID == "versions") {
processTooltip();
}
})
tool.addEventListener('click', event => {
//Check if script was called from textarea or selector
var targetID = event.target.getAttribute('id');
if (targetID !== "xmlArea" && targetID !== "transformArea") {
return;
}
processTooltip();
})
tool.addEventListener('change', event => {
//Check if script was called from textarea or selector
var targetID = event.target.getAttribute('id');
if (targetID !== "xmlArea" && targetID !== "transformArea") {
return;
}
processTooltip();
})
}
</script>
</body>
</html>