LocalName (XmlDoc/XmlNode function): Difference between revisions
m (move footer template to actual end (otherwise subsequent intervening text gets omitted); edits, tags and links) |
|||
(10 intermediate revisions by 4 users not shown) | |||
Line 4: | Line 4: | ||
==Syntax== | ==Syntax== | ||
{{Template:XmlDoc/XmlNode:LocalName syntax}} | {{Template:XmlDoc/XmlNode:LocalName syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%unicode</th> | <tr><th nowrap>%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 <var>Root</var> 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> | |||
<td>A <var>Unicode</var> string that is an [[XPath]] | <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. Any other nodes in the nodelist are ignored. | |||
<p> | |||
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></td></tr> | |||
</table> | </table> | ||
Line 18: | Line 23: | ||
<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, if the node is an <var>Element</var> or <var>Attribute</var>, respectively. This does not include any namespace prefix or following colon. | <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.</li> | ||
<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 | <li>The processing instruction's target, if the node is a <var>PI</var>. (A <var>PI</var> node does not have a namespace prefix.)</li> | ||
</ul> | |||
<li>This function may only be used if the <var>XmlDoc</var>'s Namespace property is < | <li>Other node types will return the null string.</li> | ||
<li>As of <var class="product">[[Sirius Mods | </ul></li> | ||
<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> | |||
<li>As of <var class="product">[[Sirius Mods]]</var> Version 7.3, <var>LocalName</var>'s argument and result may include only non-null EBCDIC characters that translate to Unicode. As of <var class="product">Sirius Mods</var> Version 7.6, these strings are <var>Unicode</var> or are converted to <var>Unicode</var>. | |||
<p> | <p> | ||
For more information about the effects of this version 7.6 change, see [[XmlDoc API#Strings and Unicode with the XmlDoc API| | 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></li> | ||
</ul> | </ul> | ||
==Examples== | ==Examples== | ||
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: | 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: | ||
<p class="code">begin | <p class="code">begin | ||
Line 44: | Line 52: | ||
<p class="output">bar | <p class="output">bar | ||
junk | junk | ||
</p | </p> | ||
==Request- | ==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> Namespace property not < | <li><var>XmlDoc</var> <var>[[Namespace (XmlDoc property)|Namespace]]</var> property value not <var>On</var> | ||
<li><var class="term"> | <li>The <var class="term">xpath</var> expression is invalid. | ||
<li>Result of | <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> | ||
Line 56: | Line 65: | ||
==See also== | ==See also== | ||
<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><var>[[Prefix (XmlDoc/XmlNode function)|Prefix]]</var> | <li><var>[[Prefix (XmlDoc/XmlNode function)|Prefix]]</var></li> | ||
<li><var>[[QName (XmlDoc/XmlNode function)|QName]]</var> | <li><var>[[QName (XmlDoc/XmlNode function)|QName]]</var></li> | ||
<li><var>[[URI (XmlDoc/XmlNode function)|URI]]</var> | <li><var>[[URI (XmlDoc/XmlNode function)|URI]]</var></li> | ||
</ul> | </ul></li> | ||
</ul> | </ul> | ||
{{Template:XmlDoc/XmlNode:LocalName footer}} | {{Template:XmlDoc/XmlNode:LocalName footer}} |
Latest revision as of 21:30, 2 September 2015
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. 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). |
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
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
This list is not exhaustive: it does not include all the errors that are request cancelling.
- XmlDoc Namespace property value 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: