Files
release11-tools/Frontend/tools/xpath.html
2023-03-29 08:49:43 +02:00

1117 lines
62 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: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 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:avg((arg,arg,...))</code></a>
<div class="content">
Returns the average of the argument values <br>
<b>Arguments and return type:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>sequence*</td>
<td>returns average value of provided elements</td>
</tr>
</table><b>Examples: </b><br>
<table class="table-doc">
<tr>
<th>Expression</th>
<th>Result</th>
</tr>
<tr>
<td>avg((1,2,3))</td>
<td>2</td>
</tr>
</table><br>
<code>W3C Documentation reference: <a href="https://www.w3.org/TR/xpath-functions/#func-avg" class="hyperlink" target="_blank">#func-avg</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">
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 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>