DefaultURI (XmlDoc/XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 21: Line 21:


==Examples==
==Examples==
In the following example, two elements are added along with their namespace <var>URI</var>s, but only the second added element, which has no prefix, has a default namespace <var>URI</var>:
In the following example, two elements are added along with their namespace <var>URI</var>s, but only the second added element, which has no prefix, has a default namespace URI:
<p class="code">begin
<p class="code">begin
   %d object xmlDoc auto new
   %d object xmlDoc auto new
Line 44: Line 44:
<ul>
<ul>
<li><var>XmlDoc</var> <var>[[Namespace_(XmlDoc_property)|Namespace]]</var> property value not <var>On</var>.
<li><var>XmlDoc</var> <var>[[Namespace_(XmlDoc_property)|Namespace]]</var> property value not <var>On</var>.
<li><var class="term">xpath</var> is invalid.
<li>The <var class="term">xpath</var> argument 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 54: Line 54:
<li>For more information about namespace declarations, see [[XML processing in Janus SOAP#Names and namespaces|"Names and namespaces"]].
<li>For more information about namespace declarations, see [[XML processing in Janus SOAP#Names and namespaces|"Names and namespaces"]].
<li>For more information about URIs, see [[XML_processing_in_Janus_SOAP#Uniform_Resource_Identifier_syntax|"Uniform Resource Identifier syntax"]].
<li>For more information about URIs, see [[XML_processing_in_Janus_SOAP#Uniform_Resource_Identifier_syntax|"Uniform Resource Identifier syntax"]].
<li>The <var>[[PrefixURI_(XmlDoc/XmlNode_function)|PrefixURI]]</var> method returns the <var>URI</var> bound to a node's prefix (or the default <var>URI</var>, if a node has a default namespace declaration). The <var>[[URI (XmlDoc/XmlNode function)|URI]]</var> method returns the <var>URI</var> bound to a node's name, if any.
<li>The <var>[[PrefixURI_(XmlDoc/XmlNode_function)|PrefixURI]]</var> method returns the URI bound to a node's prefix (or the default URI, if a node has a default namespace declaration). The <var>[[URI (XmlDoc/XmlNode function)|URI]]</var> method returns the URI bound to a node's name, if any.
<li>These methods add namespace <var>URI</var>s to <var>XmlDoc</var> nodes:
<li>These methods add namespace URIs to <var>XmlDoc</var> nodes:
<ul>
<ul>
<li><var>[[AddElement (XmlDoc/XmlNode function)|AddElement]]</var>
<li><var>[[AddElement (XmlDoc/XmlNode function)|AddElement]]</var>

Revision as of 21:22, 31 May 2011

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

The DefaultURI function returns 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.

Syntax

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

Syntax terms

%unicode 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.

Usage notes

  • DefaultURI is new as of Sirius Mods Version 6.9.

Examples

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 value not On.
  • The xpath argument is invalid.
  • Result of (xpath) is empty.
  • Insufficient free space exists in CCATEMP.

See also