Prefix (XmlDoc/XmlNode function): Difference between revisions
Jump to navigation
Jump to search
m (→Usage notes) |
mNo edit summary |
||
Line 12: | Line 12: | ||
<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 Root 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. An optional argument, its default is a period (<tt>.</tt>), that is, the node referenced by the method object (<i>nr</i>). | ||
Prior to | Prior to <var class="product">Sirius Mods</var> version 7.6, this is an EBCDIC string.</td></tr> | ||
</table> | </table> | ||
Line 34: | Line 34: | ||
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 | %d Object XmlDoc | ||
%d = New | %d = New | ||
%n1 | %n1 Object XmlNode | ||
%n1 = %d:AddElement('foo:bar', , 'ftp:here') | %n1 = %d:AddElement('foo:bar', , 'ftp:here') | ||
Print ' | Print 'Prefix =' And %n1:Prefix | ||
%n1 = %n1:AddElement('junk') | %n1 = %n1:AddElement('junk') | ||
Print ' | Print 'Prefix =' And %n1:Prefix | ||
End | End | ||
</p> | </p> | ||
The example result follows: | The example result follows: | ||
<p class="output" | <p class="output">Prefix = foo | ||
Prefix = | |||
</p> | </p> | ||
Line 60: | Line 60: | ||
{{Template:XmlDoc/XmlNode:Prefix footer}} | {{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|"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>[[LocalName (XmlDoc/XmlNode function)|LocalName]] | <li><var>[[LocalName (XmlDoc/XmlNode function)|LocalName]]</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> |
Revision as of 20:59, 24 May 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
%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. 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.