Prefix (XmlDoc/XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (xpath arg)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:XmlDoc/XmlNode:Prefix subtitle}}
{{Template:XmlDoc/XmlNode:Prefix subtitle}}
<var>Prefix</var> returns the "prefix" (that is, the part of the name before the colon) of the node that is the head of an XPath result.


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==
==Syntax==
{{Template:XmlDoc/XmlNode:Prefix syntax}}
{{Template:XmlDoc/XmlNode:Prefix syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%unicode</th>
<tr><th>%unicode</th>
<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 <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 Root 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 [[XPath#XPath_syntax|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#XPath_syntax|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>
Prior to ''Sirius Mods'' version 7.6, this is an EBCDIC string.</td></tr>
This is an optional argument, and its default is a period (<tt>.</tt>), that is, the node referenced by the method object (<var class="term">nr</var>). </p>
 
<p>
Prior to <var class="product">[[Sirius Mods]]</var> Version 7.6, this is an EBCDIC string.</p></td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul><li>The prefix is defined to be:
<li>The prefix is defined to be:
<ul><li>The element-type or attribute name prefix if the node is an <var>Element</var> or <var>Attribute</var>, respectively.
<ul>
<li>The element-type or attribute name prefix
if the node is an <var>Element</var> or <var>Attribute</var>, respectively.
<li>The null string, otherwise.
<li>The null string, otherwise.
</ul>
</ul>
<li>This function may only be used if the <var>XmlDoc</var>'s <var>[[Namespace (XmlDoc property)|Namespace]]</var> property is <var>On</var>.
<li>This function may only be used if the <var>XmlDoc</var>'s <var>[[Namespace (XmlDoc property)|Namespace]]</var> property value is <var>On</var>.
</ul>
</ul>


===Example===
==Examples==
 
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.
In the following example, two nodes are added to an <var>XmlDoc</var> and their name
<p class="code">begin
prefixes, one of which is the null string, are printed.
  %d object xmlDoc
<p class="code">Begin
  %d = new
%d <var>Object</var> <var>XmlDoc</var>
  %n1 object xmlNode
%d = New
  %n1 = %d:[[AddElement_(XmlDoc/XmlNode_function)|addElement]]('foo:bar', , 'ftp:here')
%n1 <var>Object</var> <var>XmlNode</var>
  print 'Prefix =' and %n1:prefix
%n1 = %d:AddElement('foo:bar', , 'ftp:here')
  %n1 = %n1:addElement('junk')
Print '<var>Prefix</var> =' And %n1:<var>Prefix</var>
  print 'Prefix =' and %n1:prefix
%n1 = %n1:AddElement('junk')
end
Print '<var>Prefix</var> =' And %n1:<var>Prefix</var>
End
</p>
</p>
The example result follows:
The example result follows:
<p class="output"><var>Prefix</var> = foo
<p class="output">Prefix = foo
<var>Prefix</var> =
Prefix =
</p>
</p>


===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>XmlDoc</var> <var>Namespace</var> property not <var>On</var>.
<li><var>XmlDoc</var> <var>Namespace</var> property not <var>On</var>.
<li><var class="term">xpath</var> is invalid.
<li>The <var class="term">xpath</var> expression is invalid.
<li>Result of <var class="term">xpath</var> is empty.
<li>Result of <var class="term">xpath</var> is empty.
<li>Insufficient free space exists in CCATEMP.
<li>Insufficient free space exists in CCATEMP.
Line 58: Line 56:


==See also==
==See also==
{{Template:XmlDoc/XmlNode:Prefix footer}}
<ul>
<ul>
<li>For more information about using XPath expressions, see [[XPath]].
<li>For more information about using XPath expressions, see [[XPath]].</li>
 
<li>These methods also obtain information about the name of a node:
<li>These methods also obtain information about the name of a node:
<ul>
<ul>
<li>[[LocalName (XmlDoc/XmlNode function)|LocalName]]
<li><var>[[LocalName (XmlDoc/XmlNode function)|LocalName]]</var></li>
<li>[[QName (XmlDoc/XmlNode function)|QName]]
<li><var>[[QName (XmlDoc/XmlNode function)|QName]]</var></li>
<li>[[URI (XmlDoc/XmlNode function)|URI]]
<li><var>[[URI (XmlDoc/XmlNode function)|URI]]</var></li>
</ul>
</ul></li>
</ul>
</ul>
{{Template:XmlDoc/XmlNode:Prefix footer}}

Latest revision as of 17:41, 18 February 2015

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

Prefix returns 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

%unicode 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. Any other nodes in the nodelist are ignored.

This is an optional argument, and 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 value is On.

Examples

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

This list is not exhaustive: it does not include all the errors that are request cancelling.

  • XmlDoc Namespace property not On.
  • The xpath expression 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: