ToXPathString (XmlDoc/XmlNode function): Difference between revisions

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


<p>
<p>
ToXPathString is a member of the [[XmlDoc class]].
ToXPathString is a member of the [[XmlDoc class|XmlDoc]] and [[XmlNode class|XmlNode]] classes.
</p>
</p>


This function returns in a string an absolute XPath expression that identifies the
This function returns in a string an absolute XPath expression that identifies the
node that a given XPath expression actually selects.
node that a given XPath expression actually selects.
ToXPathString is designed to provide additional information when sending an error
<var>ToXPathString</var> is designed to provide additional information when sending an error
message to an XML client application, helping the application to identify an
message to an XML client application, helping the application to identify an
invalid node selection in its request XML document.
invalid node selection in its request XML document.
A complex XPath expression might not be finding the node intended, for example.
A complex XPath expression might not be finding the node intended, for example.


ToXPathString is the same as XPathNodeID ([[??]] refid=xpnodid.)
<var>ToXPathString</var> is the same as <var>[[XPathNodeID (XmlDoc/XmlNode function)|XPathNodeID]]</var>
except its output is a string instead of a Stringlist
except its output is a string instead of a Stringlist
(<tt>ToXPathStringlist</tt> is a synonym for XPathNodeID).
(<var>ToXPathStringlist</var> is a synonym for <var>XPathNodeID</var>).
ToXPathString lets
<var>ToXPathString</var> lets
[[SirFact]], [[Janus Debugger]], and [[Sirius Debugger]] users extract XPath information when needed.
[[SirFact]], [[Janus Debugger]], and [[Sirius Debugger]] users extract XPath information when needed.
The XPathNodeID method does not work in those environments because of its
The XPathNodeID method does not work in those environments because of its
object (Stringlist) output.
object (Stringlist) output.


ToXPathString is new as of version 7.3 of the ''Sirius Mods''.
<var>ToXPathString</var> is new as of version 7.3 of the ''Sirius Mods''.
===Syntax===
===Syntax===
   %str = nr:ToXPathString([selection_XPath])
   %str = nr:ToXPathString([selectionXpath])


====Syntax Terms====
====Syntax Terms====
Line 31: Line 31:
<dt>%str
<dt>%str
<dd>A string or longstring
<dd>A string or longstring
that identifies the node identified by ''selection_XPath''.
that identifies the node identified by ''selectionXpath''.
<dt>nr
<dt>nr
<dd>An XmlDoc or XmlNode, used as the context node for the <i>selection_XP</i>
<dd>An XmlDoc or XmlNode, used as the context node for the <i>selectionXpath</i>
expression.
expression.
If an XmlDoc, the Root node is the context node.
If an XmlDoc, the Root node is the context node.
<dt>selection_XPath
<dt>selectionXpath
<dd>A Unicode string that is an XPath expression that selects a node
<dd>A Unicode string that is an XPath expression that selects a node
from the method object.
from the method object.
Line 94: Line 94:
===Request-Cancellation Errors===
===Request-Cancellation Errors===
<ul>
<ul>
<li><i>selection_XPath</i> is invalid.
<li><i>selectionXpath</i> is invalid.
<li>Insufficient free space exists in CCATEMP.
<li>Insufficient free space exists in CCATEMP.
</ul>
</ul>

Revision as of 21:06, 20 January 2011

XPath string expression for selected node

ToXPathString is a member of the XmlDoc and XmlNode classes.

This function returns in a string an absolute XPath expression that identifies the node that a given XPath expression actually selects. ToXPathString is designed to provide additional information when sending an error message to an XML client application, helping the application to identify an invalid node selection in its request XML document. A complex XPath expression might not be finding the node intended, for example.

ToXPathString is the same as XPathNodeID except its output is a string instead of a Stringlist (ToXPathStringlist is a synonym for XPathNodeID). ToXPathString lets SirFact, Janus Debugger, and Sirius Debugger users extract XPath information when needed. The XPathNodeID method does not work in those environments because of its object (Stringlist) output.

ToXPathString is new as of version 7.3 of the Sirius Mods.

Syntax

  %str = nr:ToXPathString([selectionXpath])

Syntax Terms

%str
A string or longstring that identifies the node identified by selectionXpath.
nr
An XmlDoc or XmlNode, used as the context node for the selectionXpath expression. If an XmlDoc, the Root node is the context node.
selectionXpath
A Unicode string that is an XPath expression that selects a node from the method object. Prior to Sirius Mods version 7.6, this is an EBCDIC string.

Usage Notes

  • If the absolute XPath expression returned by ToXPathString contains no prefixes, the string %str contains only one item: the expression. However, if the expression uses an element or attribute that has one or more non-null namespace URIs, the expression contains an additional pair of blank-delimited substrings for each such URI (a substring for the associated prefix, then a substring for the URI). Note: If the expression uses a URI that is without a prefix in the document or if a single prefix in the document is used for two different URIs, ToXPathString generates an “invented” prefix. Such a prefix is generated because an XPath expression requires a prefix if it names an element or attribute that has a URI (for more about this requirement, see SelectionNamespace). A generated prefix is shown in the example, below.

Example

The following document contained in an XmlDoc is used as the method object for ToXPathString:

    <a>
       <?p1?>
       <b>
          <c n="1"/>
          <c n="2"/>
       </b>
       <?p2?>
       <x:a xmlns:x="u:a">
          <x:b/>
          <y xmlns="u:c"/>
       </x:a>
    </a>

The following table shows the strings returned for each of various ToXPathString arguments. Notice that the last two arguments produce strings that include prefix/URI substrings.

    :hp2 color=black.
    Argument:                      Returned string:
    -----------------------------  ---------------------------
    '''
    /                              /

Request-Cancellation Errors

  • selectionXpath is invalid.
  • Insufficient free space exists in CCATEMP.