PrefixURI (XmlDoc/XmlNode function): Difference between revisions
m (→Syntax terms) |
mNo edit summary |
||
Line 18: | Line 18: | ||
<td>A <var>Unicode</var> string that is the prefix to "lookup" 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> | <td>A <var>Unicode</var> string that is the prefix to "lookup" 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 | <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></tr> | ||
</table> | </table> | ||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>As of | <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 <var> | 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. | |||
For more information about the effects of this version 7.6 | For more information about the effects of this version 7.6 | ||
change, see [[Strings and Unicode]]. | 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 Value method, see | For an example of a specific effect that involves the <var>Value</var> method, see | ||
[[Value (XmlDoc/XmlNode property)#ampexmp|this example]]. | |||
</ul> | </ul> | ||
==Example== | |||
In the following example, a node has a default URI defined as well as URIs | In the following example, a node has a default URI defined as well as URIs | ||
Line 56: | Line 56: | ||
URI bound to prefix "bar" = urn:bar | URI bound to prefix "bar" = urn:bar | ||
</p> | </p> | ||
==Request-Cancellation Errors== | |||
<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>< | <li><var class="term">xpath</var> 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 68: | Line 68: | ||
{{Template:XmlDoc/XmlNode:PrefixURI footer}} | {{Template:XmlDoc/XmlNode:PrefixURI 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>For more information about | <li>For more information about | ||
namespace declarations, see [[ | namespace declarations, see [[XML processing in Janus SOAP#Names and namespaces|"Names and namespaces"]]. | ||
<li>For more information about URIs, see [[ | <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 [[DefaultURI (XmlDoc/XmlNode function)|DefaultURI]] method returns | ||
the default URI, if a node has a default namespace declaration; | the default URI, if a node has a default namespace declaration; | ||
otherwise it returns a null string. | otherwise it returns a null string. | ||
The URI | The <var>[[URI (XmlDoc/XmlNode function)|URI]]</var> method returns the URI bound to a node's name, | ||
if any. | 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> | ||
<li>[[AddElement (XmlDoc/XmlNode function)|AddElement]] | <li><var>[[AddElement (XmlDoc/XmlNode function)|AddElement]]</var> | ||
<li>[[AddAttribute (XmlNode function)|AddAttribute]] | <li><var>[[AddAttribute (XmlNode function)|AddAttribute]]</var> | ||
<li>[[AddNamespace (XmlNode subroutine)|AddNamespace]] | <li><var>[[AddNamespace (XmlNode subroutine)|AddNamespace]]</var> | ||
</ul> | </ul> | ||
</ul> | </ul> |
Revision as of 01:06, 24 May 2011
URI of specified prefix in context of selected node (XmlDoc and XmlNode classes)
This function 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.
The PrefixURI function is new as of version 6.9 of the Sirius Mods.
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 "lookup" 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 to process. An optional argument, 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.
Example
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
- XmlDoc Namespace property value 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 "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: