DefaultURI (XmlDoc/XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 5: Line 5:
at a node that is the head of an XPath result.
at a node that is the head of an XPath result.


The DefaultURI function is new as of version 6.9 of the ''Sirius Mods''.
The <var>DefaultURI</var> function is new as of version 6.9 of the ''Sirius Mods''.
==Syntax==
==Syntax==
{{Template:XmlDoc/XmlNode:DefaultURI syntax}}
{{Template:XmlDoc/XmlNode:DefaultURI syntax}}
Line 13: Line 13:
<td>A string variable for the returned URI. </td></tr>
<td>A string variable for the returned URI. </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 24: Line 24:
namespace URI:
namespace URI:
<p class="code">Begin
<p class="code">Begin
%d Object XmlDoc Auto New
%d <var>Object</var> <var>XmlDoc</var> Auto New
%n Object XmlNode
%n <var>Object</var> <var>XmlNode</var>
%n2 Object XmlNode
%n2 <var>Object</var> <var>XmlNode</var>
%n = %d:AddElement('p:top', , 'urn:top')
%n = %d:AddElement('p:top', , 'urn:top')
%n2 = %n:AddElement('inner', , 'urn:default')
%n2 = %n:AddElement('inner', , 'urn:default')
%n:Print
%n:Print
Print 'URI of p:top default namespace =' And %n:DefaultURI
Print 'URI of p:top default namespace =' And %n:<var>DefaultURI</var>
Print 'URI of inner default namespace =' And %n2:DefaultURI
Print 'URI of inner default namespace =' And %n2:<var>DefaultURI</var>
End
End
</p>
</p>
Line 43: Line 43:
===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.
Line 61: Line 61:
The URI method ([[??]] refid=uri.) returns the URI bound to a node's name,
The URI method ([[??]] refid=uri.) returns the URI bound to a node's name,
if any.
if any.
<li>These methods add namespace URIs to XmlDoc nodes:
<li>These methods add namespace URIs to <var>XmlDoc</var> nodes:
<ul>
<ul>
<li>[[AddElement (XmlDoc/XmlNode function)|AddElement]]
<li>[[AddElement (XmlDoc/XmlNode function)|AddElement]]

Revision as of 17:46, 25 January 2011

Default URI in scope at selected node (XmlDoc and XmlNode classes)


This function gets the Uniform Resource Identifier (URI) associated with the default namespace declaration that is in scope at a node that is the head of an XPath result.

The DefaultURI function is new as of version 6.9 of the Sirius Mods.

Syntax

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

Syntax terms

%uri A string variable for the returned URI.
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.

In the following example, two elements are added along with their namespace URIs, but only the second added element, which has no prefix, has a default namespace URI:

Begin %d Object XmlDoc Auto New %n Object XmlNode %n2 Object XmlNode %n = %d:AddElement('p:top', , 'urn:top') %n2 = %n:AddElement('inner', , 'urn:default') %n:Print Print 'URI of p:top default namespace =' And %n:DefaultURI Print 'URI of inner default namespace =' And %n2:DefaultURI End

The following lines are printed:

<p:top xmlns:p="urn:top"> <inner xmlns="urn:default"/> </p:top> URI of p:top default namespace = URI of inner default namespace = urn:default

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.
  • For more information about namespace declarations, see ?? refid=namsp..
  • For more information about URIs, see ?? refid=nsuri..
  • The PrefixURI method (?? refid=prefuri.) returns the URI bound to a node's prefix (or the default URI, if a node has a default namespace declaration). The URI method (?? refid=uri.) returns the URI bound to a node's name, if any.
  • These methods add namespace URIs to XmlDoc nodes: