ValueDefault (XmlDoc/XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 1: Line 1:
{{Template:XmlDoc/XmlNode:ValueDefault subtitle}}
{{Template:XmlDoc/XmlNode:ValueDefault subtitle}}


The ValueDefault function obtains a substring of the string-value of a node, including its
The <var>ValueDefault</var> function obtains a substring of the string-value of a node, including its
Text descendants.
Text descendants.
ValueDefault provides an optional argument to use as a return value if the XPath
<var>ValueDefault</var> provides an optional argument to use as a return value if the XPath
expression that designates the node to process is empty.
expression that designates the node to process is empty.
==Syntax==
==Syntax==
Line 10: Line 10:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%str</th>
<tr><th>%str</th>
<td>A Unicode string variable for the returned substring or for the <i>default</i> value. Prior to ''Sirius Mods'' 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 ''Sirius Mods'' version 7.6, this is an EBCDIC string. </td></tr>
<tr><th>nr</th>
<tr><th>nr</th>
<td>An XmlDoc or XmlNode, used as the context node for the <i>XPath</i> expression. If an XmlDoc, the Root node is the context node. </td></tr>
<td>An <var>XmlDoc</var> or <var>XmlNode</var>, used as the context node for the <i>XPath</i> expression. If an <var>XmlDoc</var>, the Root node is the context node. </td></tr>
<tr><th>XPath</th>
<tr><th>XPath</th>
<td>A Unicode string that is an XPath expression that results in a nodelist. The head of the nodelist is the node to process.
<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.
<p class="code">This is an optional argument whose default is a period (.), that is, the node referenced by the method object (<i>nr</i>). Prior to ''Sirius Mods'' version 7.6, this argument is an EBCDIC string. </td></tr>
<p class="code">This is an optional argument whose default is a period (.), that is, the node referenced by the method object (<i>nr</i>). Prior to ''Sirius Mods'' version 7.6, this argument is an EBCDIC string. </td></tr>
</p>
</p>
<tr><th>default</th>
<tr><th>default</th>
<td>A Unicode string expression to use as the result of ValueDefault if the result of <i>XPath</i> is the empty nodelist. An optional argument, its default is the null string. Prior to ''Sirius Mods'' version 7.6, this argument is an EBCDIC string.</td></tr>
<td>A <var>Unicode</var> string expression to use as the result of <var>ValueDefault</var> if the result of <i>XPath</i> is the empty nodelist. An optional argument, its default is the null string. Prior to ''Sirius Mods'' version 7.6, this argument is an EBCDIC string.</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>As of ''Sirius Mods'' version 7.3, the ValueDefault string arguments and result
<li>As of ''Sirius Mods'' version 7.3, the <var>ValueDefault</var> string arguments and result
may include only non-null EBCDIC characters that translate to Unicode.
may include only non-null EBCDIC characters that translate to <var>Unicode</var>.
As of ''Sirius Mods'' version 7.6, these strings are Unicode or are converted to Unicode.
As of ''Sirius Mods'' 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
For more information about the effects of this version 7.6
Line 34: Line 34:
the default string, a single underscore ( _ ) character:
the default string, a single underscore ( _ ) character:
<p class="code">Begin
<p class="code">Begin
%d Object XmlDoc
%d <var>Object</var> <var>XmlDoc</var>
%d = New
%d = New
%d:LoadXml('<t>Test</t>')
%d:LoadXml('<t>Test</t>')
Print %d:ValueDefault('/x', '_')
Print %d:<var>ValueDefault</var>('/x', '_')
End
End
</p>
</p>

Revision as of 17:46, 25 January 2011

String-value of selected node (allow empty XPath) (XmlDoc and XmlNode classes)


The ValueDefault function 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

%str 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.

This is an optional argument whose default is a period (.), that is, the node referenced by the method object (nr). Prior to Sirius Mods version 7.6, this argument is an EBCDIC string.

default A Unicode string expression to use as the result of ValueDefault if the result of XPath is the 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 string arguments and result 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.

Example

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

  • XPath 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.