LocalName (XmlDoc/XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (move footer template to actual end (otherwise subsequent intervening text gets omitted); edits, tags and links)
Line 1: Line 1:
{{Template:XmlDoc/XmlNode:LocalName subtitle}}
{{Template:XmlDoc/XmlNode:LocalName subtitle}}
<var>LocalName</var> returns the "local name" (the name ignoring any prefix and colon) of the node that is the head of an [[XPath]] result.


This function gets the "local name" (the name ignoring any
prefix and colon) of the node that is the head of an XPath result.
==Syntax==
==Syntax==
{{Template:XmlDoc/XmlNode:LocalName syntax}}
{{Template:XmlDoc/XmlNode:LocalName syntax}}
Line 8: Line 7:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%unicode</th>
<tr><th>%unicode</th>
<td>A <var>Unicode</var> string variable for the returned name. </td></tr>
<td>A <var>Unicode</var> string variable for the returned name.</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><var>XPath</var></th>
<tr><th><var>XPath</var></th>
<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>).</td></tr>
<td>A <var>Unicode</var> string that is an [[XPath]] expression that results in a <var>nodelist</var>. The head of the <var>nodelist</var> is the node to process. An optional argument, its default is a period (<code>.</code>), that is, the node referenced by the method object (<var class="term">nr</var>).</td></tr>
</table>
</table>


Line 19: Line 18:
<li>The local name is defined to be:
<li>The local name is defined to be:
<ul>
<ul>
<li>The local part of the element-type or attribute name,
<li>The local part of the element-type or attribute name, if the node is an <var>Element</var> or <var>Attribute</var>, respectively. This does not include any namespace prefix or following colon.
if the node is an Element or Attribute, respectively.
<li>The processing instruction's target, if the node is a PI. (A PI node does not have a namespace prefix.)
This does not include any namespace prefix or following colon.
<li>Other node types will return the <var>null</var> string.
<li>The processing instruction's target, if the node is a PI.
(A PI node does not have a namespace prefix.)
<li>Other node types will return the null string.
</ul>
</ul>
<li>This function may only be used if the <var>XmlDoc</var>'s Namespace property
<li>This function may only be used if the <var>XmlDoc</var>'s Namespace property is <code>On</code>.
is <tt>On</tt>.
<li>As of <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.3, <var>LocalName</var>'s argument and result may include only non-null EBCDIC characters that translate to <var>Unicode</var>. As of <var class="product">"Sirius Mods"</var> Version 7.6, these strings are <var>Unicode</var> or are converted to <var>Unicode</var>.
<li>As of ''Sirius Mods'' version 7.3, <var>LocalName</var>'s argument and result may include
<p>
only non-null EBCDIC characters that translate 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"]]. For an example of a specific effect that involves the <var>Value</var> method, see [[Value (XmlDoc/XmlNode property)#ampexmp|this example]].</p>
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
change, see [[XmlDoc API#Strings and Unicode with the XmlDoc API|"Strings and Unicode with the XmlDoc API"]].
For an example of a specific effect that involves the <var>Value</var> method, see [[Value (XmlDoc/XmlNode property)#ampexmp|this example]].
</ul>
</ul>


===Example===
==Examples==
 
<ol><li>
In the following example, the part of the first
In the following example, the part of the first name after the colon, and the entire second name (which does not have a prefix) are printed:
name after the colon, and the entire second name (which does
<p class="code">begin
not have a prefix) are printed:
  %d oject 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 %n1:LocalName<
%n1 = %d:AddElement('foo:bar', , 'ftp:here')
  %n1 = %n1:AddElement('junk')
Print %n1:<var>LocalName</var>
  Print %n1:LocalName
%n1 = %n1:AddElement('junk')
end
Print %n1:<var>LocalName</var>
End
</p>
</p>
The example result follows:
The example result follows:
<p class="output">bar
<p class="output">bar
junk
junk
</p>
</p></ol>


===Request-Cancellation Errors===
==Request-Cancellation Errors==
<ul>
<ul>
<li><var>XmlDoc</var> Namespace property not <tt>On</tt>
<li><var>XmlDoc</var> Namespace property not <code>On</code>
<li><i>XPath</i> is invalid.
<li><var class="term">XPath</var> is invalid.
<li>Result of (<i>XPath</i>) 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.
</ul>
</ul>


==See also==
==See also==
{{Template:XmlDoc/XmlNode:LocalName footer}}
<ul>
<ul>
<li>For more information about using XPath expressions, see [[XPath]].
<li>For more information about using XPath expressions, see [[XPath]].
<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>[[Prefix (XmlDoc/XmlNode function)|Prefix]]
<li><var>[[Prefix (XmlDoc/XmlNode function)|Prefix]]</var>
<li>[[QName (XmlDoc/XmlNode function)|QName]]
<li><var>[[QName (XmlDoc/XmlNode function)|QName]]</var>
<li>[[URI (XmlDoc/XmlNode function)|URI]]
<li><var>[[URI (XmlDoc/XmlNode function)|URI]]</var>
</ul>
</ul>
</ul>
</ul>
{{Template:XmlDoc/XmlNode:LocalName footer}}

Revision as of 05:51, 7 May 2011

Name (without prefix) of selected node (XmlDoc and XmlNode classes)

LocalName returns the "local name" (the name ignoring any prefix and colon) of the node that is the head of an XPath result.

Syntax

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

Syntax terms

%unicode A Unicode string variable for the returned name.
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).

Usage notes

  • The local name is defined to be:
    • The local part of the element-type or attribute name, if the node is an Element or Attribute, respectively. This does not include any namespace prefix or following colon.
    • The processing instruction's target, if the node is a PI. (A PI node does not have a namespace prefix.)
    • Other node types will return the null string.
  • This function may only be used if the XmlDoc's Namespace property is On.
  • As of "Sirius Mods" Version 7.3, LocalName's argument 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 with the XmlDoc API". For an example of a specific effect that involves the Value method, see this example.

Examples

  1. In the following example, the part of the first name after the colon, and the entire second name (which does not have a prefix) are printed:

    begin %d oject xmlDoc %d = new %n1 object xmlNode %n1 = %d:addElement('foo:bar', , 'ftp:here') Print %n1:LocalName< %n1 = %n1:AddElement('junk') Print %n1:LocalName end

    The example result follows:

    bar junk

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: