Prefix (XmlDoc/XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 10: Line 10:
<td>A string variable for the returned prefix. </td></tr>
<td>A string variable for the returned prefix. </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. An optional argument, its default is a period (.), that is, the node referenced by the method object (<i>nr</i>).
<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. An optional argument, its default is a period (.), that is, the node referenced by the method object (<i>nr</i>).
<p class="code">Prior to ''Sirius Mods'' version 7.6, this is an EBCDIC string.</td></tr>
<p class="code">Prior to ''Sirius Mods'' version 7.6, this is an EBCDIC string.</td></tr>
</p>
</p>
Line 25: Line 25:
<li>The null string, otherwise.
<li>The null string, otherwise.
</ul>
</ul>
<li>This function may only be used if the XmlDoc's Namespace property is <tt>On</tt>.
<li>This function may only be used if the <var>XmlDoc</var>'s Namespace property is <tt>On</tt>.
</ul>
</ul>


===Example===
===Example===


In the following example, two nodes are added to an XmlDoc and their name
In the following example, two nodes are added to an <var>XmlDoc</var> and their name
prefixes, one of which is the null string, are printed.
prefixes, one of which is the null string, are printed.
<p class="code">Begin
<p class="code">Begin
%d Object XmlDoc
%d <var>Object</var> <var>XmlDoc</var>
%d = New
%d = New
%n1 Object XmlNode
%n1 <var>Object</var> <var>XmlNode</var>
%n1 = %d:AddElement('foo:bar', , 'ftp:here')
%n1 = %d:AddElement('foo:bar', , 'ftp:here')
Print 'Prefix =' And %n1:Prefix
Print '<var>Prefix</var> =' And %n1:<var>Prefix</var>
%n1 = %n1:AddElement('junk')
%n1 = %n1:AddElement('junk')
Print 'Prefix =' And %n1:Prefix
Print '<var>Prefix</var> =' And %n1:<var>Prefix</var>
End
End
</p>
</p>


The example result follows:
The example result follows:
<p class="output">Prefix = foo
<p class="output"><var>Prefix</var> = foo
Prefix =
<var>Prefix</var> =
</p>
</p>


===Request-Cancellation Errors===
===Request-Cancellation Errors===
<ul>
<ul>
<li>XmlDoc Namespace property not <tt>On</tt>.
<li><var>XmlDoc</var> Namespace property not <tt>On</tt>.
<li><i>XPath</i> is invalid.
<li><i>XPath</i> is invalid.
<li>Result of (<i>XPath</i>) is empty.
<li>Result of (<i>XPath</i>) is empty.

Revision as of 17:46, 25 January 2011

Prefix part of name of selected node (XmlDoc and XmlNode classes)


This function gets the "prefix" (that is, the part of the name before the colon) of the node that is the head of an XPath result.

Syntax

%unicode = nr:Prefix[( [xpath])] Throws XPathError

Syntax terms

%pref A string variable for the returned prefix.
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. An optional argument, its default is a period (.), that is, the node referenced by the method object (nr).

Prior to Sirius Mods version 7.6, this is an EBCDIC string.

Usage notes

  • The prefix is defined to be:
    • The element-type or attribute name prefix if the node is an Element or Attribute, respectively.
    • The null string, otherwise.
  • This function may only be used if the XmlDoc's Namespace property is On.

Example

In the following example, two nodes are added to an XmlDoc and their name prefixes, one of which is the null string, are printed.

Begin %d Object XmlDoc %d = New %n1 Object XmlNode %n1 = %d:AddElement('foo:bar', , 'ftp:here') Print 'Prefix =' And %n1:Prefix %n1 = %n1:AddElement('junk') Print 'Prefix =' And %n1:Prefix End

The example result follows:

Prefix = foo Prefix =

Request-Cancellation Errors

  • XmlDoc Namespace property not On.
  • XPath is invalid.
  • Result of (XPath) is empty.
  • Insufficient free space exists in CCATEMP.


See also

  • For more information about using XPath expressions, see XPath.
  • These methods also obtain information about the name of a node: