Value (XmlDoc/XmlNode property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 10: Line 10:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%curr</th>
<tr><th>%curr</th>
<td>A Unicode string that is the string-value of the context node. Prior to ''Sirius Mods'' version 7.6, this is an EBCDIC string. </td></tr>
<td>A <var>Unicode</var> string that is the string-value of the context node. 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>An XPath expression that results in a nodelist, the head of which is the node to process. An optional argument, its default is a period (.), that is, the node referenced by the method object (<i>nr</i>). </td></tr>
<td>An XPath expression that results in a nodelist, the head of which is the node to process. An optional argument, its default is a period (.), that is, the node referenced by the method object (<i>nr</i>). </td></tr>
<tr><th>newvalue</th>
<tr><th>newvalue</th>
<td>A Unicode string that is the string-value to assign to the context node's Value property. Prior to ''Sirius Mods'' version 7.6, this is an EBCDIC string.</td></tr>
<td>A <var>Unicode</var> string that is the string-value to assign to the context node's <var>Value</var> property. Prior to ''Sirius Mods'' version 7.6, this is an EBCDIC string.</td></tr>
</table>
</table>


Line 22: Line 22:
<ul>
<ul>
<li>As of ''Sirius Mods'' version 7.3, the string terms in the method syntax may include
<li>As of ''Sirius Mods'' version 7.3, the string terms in the method syntax may include
only non-null EBCDIC characters that translate to Unicode.
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
change, see [[Strings and Unicode]].
change, see [[Strings and Unicode]].
For an example of a specific effect that involves the Value method, see
For an example of a specific effect that involves the <var>Value</var> method, see
item [[??]] refid=univalx..
item [[??]] refid=univalx..
<li>The string-value of a node depends on the node's type:
<li>The string-value of a node depends on the node's type:
<dl>
<dl>
<dt>Node type
<dt>Node type
<dd>String-value
<dd><var>String</var>-value
<dt>Attribute
<dt>Attribute
<dd>The normalized attribute value (see [[??]] refid=norval.)
<dd>The normalized attribute value (see [[??]] refid=norval.)
Line 44: Line 44:
whitespace immediately following the target
whitespace immediately following the target
</dl>
</dl>
<li>Value is '''not''' allowed to be set if
<li><var>Value</var> is '''not''' allowed to be set if
the head of the argument XPath result is
the head of the argument XPath result is
the Root or is an Element with a non-text child.
the Root or is an Element with a non-text child.
Line 53: Line 53:
the string "Hello, world!":
the string "Hello, world!":
<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><a>Hell</a>' With '<b>o, world!'</b></t>')
%d:LoadXml('<t><a>Hell</a>' With '<b>o, world!'</b></t>')
Print %d:Value('/t')
Print %d:<var>Value</var>('/t')
End
End
</p>
</p>
<li>The following example assigns a new value to the "billRate" element:
<li>The following example assigns a new value to the "billRate" element:
<p class="code">%worker:Value('billRate') = %worker:Value('billRate') - 10
<p class="code">%worker:<var>Value</var>('billRate') = %worker:<var>Value</var>('billRate') - 10
</p>
</p>
<li>In the following request run under ''Sirius Mods'' version 7.6 or greater,
<li>In the following request run under ''Sirius Mods'' version 7.6 or greater,
an ampersand (<tt>&</tt>) in an Element value is returned by the Value method
an ampersand (<tt>&</tt>) in an Element value is returned by the <var>Value</var> method
and displayed by two Print statements.
and displayed by two Print statements.
<p class="code">Begin
<p class="code">Begin
%d Object XmlDoc Auto New
%d <var>Object</var> <var>XmlDoc</var> Auto New
%nodeX is XmlNode
%nodeX is <var>XmlNode</var>
%nodeY is XmlNode
%nodeY is <var>XmlNode</var>
%ebc is longstring
%ebc is longstring


Line 74: Line 74:
%nodeX = %nodeY:AddElement('abc', 'Jack & Jill')
%nodeX = %nodeY:AddElement('abc', 'Jack & Jill')


%ebc = %nodeX:Value
%ebc = %nodeX:<var>Value</var>
Print %ebc
Print %ebc


Print %nodeX:Value
Print %nodeX:<var>Value</var>
End
End
</p>
</p>
Line 86: Line 86:
</p>
</p>


Because the Unicode string returned from Value in the example above
Because the <var>Unicode</var> string returned from <var>Value</var> in the example above
is assigned to an EBCDIC variable before it is printed for the first time,
is assigned to an EBCDIC variable before it is printed for the first time,
the initial Print statement simply displays the EBCDIC variable value as is.
the initial Print statement simply displays the EBCDIC variable value as is.
The assignment to EBCDIC causes a straight character-by-character conversion
The assignment to EBCDIC causes a straight character-by-character conversion
using the current Unicode translation tables.
using the current <var>Unicode</var> translation tables.


The second Print statement has to convert the Unicode value returned by the
The second Print statement has to convert the <var>Unicode</var> value returned by the
Value expression.
<var>Value</var> expression.
For this, under ''Sirius Mods'' version 7.6 or greater, Print uses character encoding for
For this, under ''Sirius Mods'' version 7.6 or greater, Print uses character encoding for
any Unicode characters that do not translate to EBCDIC, and
any <var>Unicode</var> characters that do not translate to EBCDIC, and
an ampersand is converted to to the string <tt>&amp;amp;</tt>.
an ampersand is converted to to the string <tt>&amp;amp;</tt>.
In effect, Print calls the UnicodeToEbcdic method ([[??]] refid=fu2e.)
In effect, Print calls the <var>Unicode</var>ToEbcdic method ([[??]] refid=fu2e.)
with parameter setting <tt>CharacterEncode=True</tt> to implicitly
with parameter setting <tt>CharacterEncode=True</tt> to implicitly
convert the Unicode value.
convert the <var>Unicode</var> value.
Implicit Unicode conversions are further described [[??]] reftxt=* refid=uniconv..
Implicit <var>Unicode</var> conversions are further described [[??]] reftxt=* refid=uniconv..
</ol>
</ol>


Line 114: Line 114:
{{Template:XmlDoc/XmlNode:Value footer}}
{{Template:XmlDoc/XmlNode:Value footer}}
<ul>
<ul>
<li>[[??]] reftxt=ValueDefault refid=valdf. is a function
<li>[[??]] reftxt=<var>Value</var>Default refid=valdf. is a function
that obtains a node's string value and
that obtains a node's string value and
that allows an empty XPath result.
that allows an empty XPath result.
<li>For more information about using XPath expressions, see [[XPath]].
<li>For more information about using XPath expressions, see [[XPath]].
</ul>
</ul>

Revision as of 17:46, 25 January 2011

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


This settable property obtains a substring of the XPath "string-value" of a node, including its Text descendants. The string-value depends on the node type, as shown in "Usage Notes," below.

Syntax

%currentUnicode = nr:Value[( [xpath])] nr:Value[( [xpath])] = newUnicode Throws XPathError

Syntax terms

%curr A Unicode string that is the string-value of the context node. 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 An XPath expression that results in a nodelist, the head of which is the node to process. An optional argument, its default is a period (.), that is, the node referenced by the method object (nr).
newvalue A Unicode string that is the string-value to assign to the context node's Value property. Prior to Sirius Mods version 7.6, this is an EBCDIC string.

Usage notes

  • As of Sirius Mods version 7.3, the string terms in the method syntax 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. For an example of a specific effect that involves the Value method, see item ?? refid=univalx..
  • The string-value of a node depends on the node's type:
    Node type
    String-value
    Attribute
    The normalized attribute value (see ?? refid=norval.)
    Comment or Text
    The content of the node
    Element or Root
    The concatenation of the value of all its Text descendants, in document order
    PI
    The portion of the processing instruction following its target and any whitespace immediately following the target
  • Value is not allowed to be set if the head of the argument XPath result is the Root or is an Element with a non-text child.

Examples

  1. The following example displays the string "Hello, world!":

    Begin %d Object XmlDoc %d = New %d:LoadXml('<t><a>Hell</a>' With 'o, world!'</t>') Print %d:Value('/t') End

  2. The following example assigns a new value to the "billRate" element:

    %worker:Value('billRate') = %worker:Value('billRate') - 10

  3. In the following request run under Sirius Mods version 7.6 or greater, an ampersand (&) in an Element value is returned by the Value method and displayed by two Print statements.

    Begin %d Object XmlDoc Auto New %nodeX is XmlNode %nodeY is XmlNode %ebc is longstring %nodeY = %d:AddElement('top') %nodeX = %nodeY:AddElement('abc', 'Jack & Jill') %ebc = %nodeX:Value Print %ebc Print %nodeX:Value End

    The result is:

    Jack & Jill Jack &amp; Jill

    Because the Unicode string returned from Value in the example above is assigned to an EBCDIC variable before it is printed for the first time, the initial Print statement simply displays the EBCDIC variable value as is. The assignment to EBCDIC causes a straight character-by-character conversion using the current Unicode translation tables.

    The second Print statement has to convert the Unicode value returned by the Value expression. For this, under Sirius Mods version 7.6 or greater, Print uses character encoding for any Unicode characters that do not translate to EBCDIC, and an ampersand is converted to to the string &amp;. In effect, Print calls the UnicodeToEbcdic method (?? refid=fu2e.) with parameter setting CharacterEncode=True to implicitly convert the Unicode value. Implicit Unicode conversions are further described ?? reftxt=* refid=uniconv..

Request-Cancellation Errors

  • XPath is invalid.
  • Result of (XPath) is empty.
  • Insufficient free space exists in CCATEMP.


See also

  • ?? reftxt=ValueDefault refid=valdf. is a function that obtains a node's string value and that allows an empty XPath result.
  • For more information about using XPath expressions, see XPath.