PrefixURI (XmlDoc/XmlNode function): Difference between revisions
m (1 revision) |
|||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{Template:XmlDoc/XmlNode:PrefixURI subtitle}} | {{Template:XmlDoc/XmlNode:PrefixURI subtitle}} | ||
<var>PrefixURI</var> can get the Uniform Resource Identifier (URI) associated with a prefix, or it can get the default URI (if a node has a default namespace declaration), in the context of a node that is the head of an XPath result. | |||
==Syntax== | ==Syntax== | ||
{{Template:XmlDoc/XmlNode:PrefixURI syntax}} | {{Template:XmlDoc/XmlNode:PrefixURI syntax}} | ||
Line 14: | Line 9: | ||
<td>A <var>Unicode</var> string variable for the returned URI. </td></tr> | <td>A <var>Unicode</var> string variable for the returned URI. </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>prefix</th> | <tr><th>prefix</th> | ||
<td>A <var>Unicode</var> string that is the prefix to " | <td>A <var>Unicode</var> string that is the prefix to "look up" in the <var>XmlDoc</var>. If this is the null string, the <var class="term">%unicode</var> result is the default namespace at the node to process. Otherwise, the <var class="term">%unicode</var> result is the URI bound to <var class="term">prefix</var> by a namespace declaration in scope at the node to process. In either case, the <var class="term">%unicode</var> result is null if there is no namespace associated with <var class="term">prefix</var>. The prefix length must be at most 255 characters. </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 | <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 used as the XML document context for the URI lookup. 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> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>As of <var class="product">Sirius Mods</var> | <li>As of <var class="product">[[Sirius Mods]]</var> Version 7.3, the method's arguments 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 Unicode or are converted to Unicode. | ||
only non-null EBCDIC characters that translate to Unicode. | <p>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 <var class="product">Sirius Mods</var> | |||
For more information about the effects of this | |||
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> | ||
In the following example, a node has a default URI defined as well as URIs | ==Examples== | ||
for two prefixes. | In the following example, a node has a default URI defined as well as URIs for two prefixes. <var>PrefixURI</var> calls return the three URIs: | ||
<var>PrefixURI</var> calls return the three URIs: | <p class="code">begin | ||
<p class="code"> | %d object xmlDoc auto new | ||
%d | %n object xmlNode | ||
%n | %n = %d:[[AddElement_(XmlDoc/XmlNode_function)|addElement]]('x', , 'urn:default') | ||
%n = %d: | %n:[[AddNamespace_(XmlNode_subroutine)|addNamespace]]('foo', 'urn:foo') | ||
%n: | %n:addNamespace('bar', 'urn:bar') | ||
%n: | %n:[[Print_(XmlDoc/XmlNode_subroutine)|print]] | ||
%n: | print 'Default namespace URI =' and %n:prefixURI('') | ||
print 'URI bound to prefix "foo" =' and %n:prefixURI('foo') | |||
print 'URI bound to prefix "bar" =' and %n:prefixURI('bar') | |||
end | |||
</p> | </p> | ||
The following lines are printed: | The following lines are printed: | ||
<p class=" | <p class="output"><x xmlns="urn:default" xmlns:foo="urn:foo" xmlns:bar="urn:bar"/> | ||
Default namespace URI = urn:default | Default namespace URI = urn:default | ||
URI bound to prefix "foo" = urn:foo | URI bound to prefix "foo" = urn:foo | ||
URI bound to prefix "bar" = urn:bar | URI bound to prefix "bar" = urn:bar | ||
</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> <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> expression 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. | ||
</ul> | </ul> | ||
==See also== | ==See also== | ||
<ul> | <ul> | ||
<li>For more information about using XPath expressions, see [[XPath|"XPath"]]. | <li>For more information about using XPath expressions, see [[XPath|"XPath"]]. | ||
<li>For more information about | <li>For more information about namespace declarations, see [[XML processing in Janus SOAP#Names and namespaces|"Names and namespaces"]]. | ||
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 [[DefaultURI (XmlDoc/XmlNode function)|DefaultURI]] method returns | <li>The <var>[[DefaultURI (XmlDoc/XmlNode function)|DefaultURI]]</var> method returns the default URI, if a node has a default namespace declaration; otherwise it returns a null string. The <var>[[URI (XmlDoc/XmlNode function)|URI]]</var> method returns the URI bound to a node's name, if any. | ||
the default URI, if a node has a default namespace declaration; | |||
otherwise it returns a null string. | |||
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 URIs to <var>XmlDoc</var> nodes: | <li>These methods add namespace URIs to <var>XmlDoc</var> nodes: | ||
<ul> | <ul> | ||
Line 84: | Line 66: | ||
</ul> | </ul> | ||
</ul> | </ul> | ||
{{Template:XmlDoc/XmlNode:PrefixURI footer}} |
Latest revision as of 20:55, 19 February 2015
URI of specified prefix in context of selected node (XmlDoc and XmlNode classes)
PrefixURI can get the Uniform Resource Identifier (URI) associated with a prefix, or it can get the default URI (if a node has a default namespace declaration), in the context of a node that is the head of an XPath result.
Syntax
%unicode = nr:PrefixURI( prefix, [xpath]) Throws XPathError
Syntax terms
%unicode | A Unicode 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. |
prefix | A Unicode string that is the prefix to "look up" in the XmlDoc. If this is the null string, the %unicode result is the default namespace at the node to process. Otherwise, the %unicode result is the URI bound to prefix by a namespace declaration in scope at the node to process. In either case, the %unicode result is null if there is no namespace associated with prefix. The prefix length must be at most 255 characters. |
xpath | A Unicode string that is an XPath expression that results in a nodelist. The head of the nodelist is the node used as the XML document context for the URI lookup. 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
- As of Sirius Mods Version 7.3, the method's arguments 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, a node has a default URI defined as well as URIs for two prefixes. PrefixURI calls return the three URIs:
begin %d object xmlDoc auto new %n object xmlNode %n = %d:addElement('x', , 'urn:default') %n:addNamespace('foo', 'urn:foo') %n:addNamespace('bar', 'urn:bar') %n:print print 'Default namespace URI =' and %n:prefixURI('') print 'URI bound to prefix "foo" =' and %n:prefixURI('foo') print 'URI bound to prefix "bar" =' and %n:prefixURI('bar') end
The following lines are printed:
<x xmlns="urn:default" xmlns:foo="urn:foo" xmlns:bar="urn:bar"/> Default namespace URI = urn:default URI bound to prefix "foo" = urn:foo URI bound to prefix "bar" = urn:bar
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".
- For more information about namespace declarations, see "Names and namespaces".
- For more information about URIs, see "Uniform Resource Identifier syntax".
- The DefaultURI method returns the default URI, if a node has a default namespace declaration; otherwise it returns a null string. The URI method returns the URI bound to a node's name, if any.
- These methods add namespace URIs to XmlDoc nodes: