ValueDefault (XmlDoc/XmlNode function): Difference between revisions
m (1 revision) |
m (xpath arg) |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{Template:XmlDoc/XmlNode:ValueDefault subtitle}} | {{Template:XmlDoc/XmlNode:ValueDefault subtitle}} | ||
<var>ValueDefault</var> obtains a substring of the string-value of a node, including its <var>Text</var> descendants. <var>ValueDefault</var> provides an optional argument to use as a return value if the [[XPath#XPath_syntax| | <var>ValueDefault</var> obtains a substring of the string-value of a node, including its <var>Text</var> descendants. <var>ValueDefault</var> provides an optional argument to use as a return value if the [[XPath#XPath_syntax|XPath expression]] that designates the node to process is empty. | ||
==Syntax== | ==Syntax== | ||
{{Template:XmlDoc/XmlNode:ValueDefault syntax}} | {{Template:XmlDoc/XmlNode:ValueDefault syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%unicode</th> | <tr><th>%unicode</th> | ||
<td>A <var>Unicode</var> string variable for the returned substring or for the <i>default</i> value. Prior to <var class="product">[[Sirius Mods]]</var> Version 7.6, this is an EBCDIC string.</td></tr> | <td>A <var>Unicode</var> string variable for the returned substring or for the <i>default</i> value. Prior to <var class="product">[[Sirius Mods]]</var> Version 7.6, this is an EBCDIC string.</td></tr> | ||
<tr><th>nr</th> | <tr><th>nr</th> | ||
<td>An <var>XmlDoc</var> or <var>XmlNode</var>, used as the context node for the <var class="term">xpath</var> expression. If an <var>XmlDoc</var>, the <var>Root</var> node is the context node. </td></tr> | <td>An <var>XmlDoc</var> or <var>XmlNode</var>, used as the context node for the <var class="term">xpath</var> expression. If an <var>XmlDoc</var>, the <var>Root</var> node is the context node. </td></tr> | ||
<tr><th>xpath</th> | <tr><th>xpath</th> | ||
<td>A <var>Unicode</var> string that is an | <td>A <var>Unicode</var> string that is an XPath expression that results in a nodelist. The head of the nodelist is the node to process. Any other nodes in the nodelist are ignored. | ||
<p>This is an optional argument whose default is a period (<code>.</code>), that is, the node referenced by the method object (<var class="term">nr</var>). Prior to <var class="product">Sirius Mods</var> Version 7.6, this argument is an EBCDIC string.</p></td></tr> | <p> | ||
This is an optional argument whose default is a period (<code>.</code>), that is, the node referenced by the method object (<var class="term">nr</var>). Prior to <var class="product">Sirius Mods</var> Version 7.6, this argument is an EBCDIC string.</p></td></tr> | |||
<tr><th>value</th> | <tr><th>value</th> | ||
<td>A <var>Unicode</var> string expression to use as the result of <var>ValueDefault</var> if the result of <var class="term">xpath</var> is | <td>A <var>Unicode</var> string expression to use as the result of <var>ValueDefault</var> if the result of <var class="term">xpath</var> is an empty nodelist. An optional argument, its default is the null string. Prior to <var class="product">Sirius Mods</var> Version 7.6, this argument is an EBCDIC string.</td></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>As of <var class="product">Sirius Mods</var> Version 7.3, the <var>ValueDefault</var> result and string arguments may include only non-null EBCDIC characters that translate to | <li>As of <var class="product">Sirius Mods</var> Version 7.3, the <var>ValueDefault</var> result and string arguments may include only non-null EBCDIC characters that translate to Unicode. | ||
<p>As of <var class="product">Sirius Mods</var> Version 7.6, these strings are <var>Unicode</var> or are converted to <var>Unicode</var>. For more information about the effects of this Version 7.6 change, see [[XmlDoc API#Strings and Unicode with the XmlDoc API| | <p>As of <var class="product">Sirius Mods</var> Version 7.6, these strings are <var>Unicode</var> or are converted to <var>Unicode</var>. For more information about the effects of this Version 7.6 change, see [[XmlDoc API#Strings and Unicode with the XmlDoc API|Strings and Unicode with the XmlDoc API]].</p> | ||
</ul> | </ul> | ||
Line 34: | Line 39: | ||
==Request-cancellation errors== | ==Request-cancellation errors== | ||
This list is not exhaustive: it does <i>not</i> include all the errors that are request cancelling. | |||
<ul> | <ul> | ||
<li><var class="term">xpath</var> is invalid. | <li><var class="term">xpath</var> expression is invalid. | ||
<li>Insufficient free space exists in CCATEMP. | <li>Insufficient free space exists in CCATEMP. | ||
</ul> | </ul> | ||
Line 42: | Line 48: | ||
<ul> | <ul> | ||
<li><var>[[Value (XmlDoc/XmlNode property)|Value]]</var> discusses the '''string-value''' of various <var>node</var> types. | <li><var>[[Value (XmlDoc/XmlNode property)|Value]]</var> discusses the '''string-value''' of various <var>node</var> types. | ||
<li>For more information about using XPath expressions, see <var>[[XPath | <li>For more information about using XPath expressions, see <var>[[XPath]]</var>. | ||
</ul> | </ul> | ||
{{Template:XmlDoc/XmlNode:ValueDefault footer}} | {{Template:XmlDoc/XmlNode:ValueDefault footer}} |
Latest revision as of 18:12, 18 February 2015
String-value of selected node (allow empty XPath) (XmlDoc and XmlNode classes)
ValueDefault obtains a substring of the string-value of a node, including its Text descendants. ValueDefault provides an optional argument to use as a return value if the XPath expression that designates the node to process is empty.
Syntax
%unicode = nr:ValueDefault[( [xpath], [value])] Throws XPathError
Syntax terms
%unicode | A Unicode string variable for the returned substring or for the default value. Prior to Sirius Mods Version 7.6, this is an EBCDIC string. |
---|---|
nr | An XmlDoc or XmlNode, used as the context node for the xpath expression. If an XmlDoc, the Root node is the context node. |
xpath | A Unicode string that is an XPath expression that results in a nodelist. The head of the nodelist is the node to process. Any other nodes in the nodelist are ignored.
This is an optional argument whose default is a period ( |
value | A Unicode string expression to use as the result of ValueDefault if the result of xpath is an empty nodelist. An optional argument, its default is the null string. Prior to Sirius Mods Version 7.6, this argument is an EBCDIC string. |
Usage notes
- As of Sirius Mods Version 7.3, the ValueDefault result and string arguments may include only non-null EBCDIC characters that translate to Unicode.
As of Sirius Mods Version 7.6, these strings are Unicode or are converted to Unicode. For more information about the effects of this Version 7.6 change, see Strings and Unicode with the XmlDoc API.
Examples
The following example displays the default string, a single underscore ( _ ) character:
begin %d object xmlDoc %d = new %d:loadXml('<t>Test</t>') print %d:valueDefault('/x', '_') end
Request-cancellation errors
This list is not exhaustive: it does not include all the errors that are request cancelling.
- xpath expression is invalid.
- Insufficient free space exists in CCATEMP.
See also
- Value discusses the string-value of various node types.
- For more information about using XPath expressions, see XPath.