XPathError class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
m (link repair)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
<!-- XPathError class -->
__NOTOC__
__NOTOC__
An <var>XPathError</var> exception can be thrown by various methods in the [[XmlDoc API]].  It indicates an error either in the syntax of an [[XPath]] argument to the method, or in the results returned by that XPath expression.  The various read-only properties of an <var>XPathError</var> object (which can be set by the <var>[[Exceptions#Try and Catch|Catch]]</var> statement) provide information about the failed operation.
An <var>XPathError</var> exception can be thrown by various methods in the [[XmlDoc API]].  It indicates an error either in the syntax of an [[XPath]] argument to the method, or in the results returned by that XPath expression.  The various read-only properties of an <var>XPathError</var> object (which can be set by the <var>[[Exceptions#Try and Catch|Catch]]</var> statement) provide information about the failed operation.
Line 21: Line 20:
</p>
</p>


This class is new in version 7.8 of the <var class="prod">Sirius Mods</var>.
This class is new in version 7.8 of the <var class="product">[[Sirius Mods]]</var>.




Line 29: Line 28:
The methods in the class are described in the subsections that follow. In addition:
The methods in the class are described in the subsections that follow. In addition:
<ul>
<ul>
<li>[[Notation conventions for methods|"Notation conventions for methods"]] has information
<li>[[Notation conventions for methods]] has information about the conventions followed. </li>
about the conventions followed.  
<li>[[XPathError methods syntax]] is a single page that contains the syntax diagrams of all the methods in the class. </li>
<li>[[XPathError methods syntax|"XPathError methods syntax"]] is a single page that contains the syntax diagrams of all the methods in the class.
</ul>
</ul>


Line 86: Line 84:
<tr><th><var>Reason</var></th>
<tr><th><var>Reason</var></th>
<td>This [[Methods#Named parameters|name required]] parameter is an <var>[[#XPathErrorReason enumeration|XPathErrorReason]]</var> enumeration value which specifies the value to be assigned to the exception object's <var>[[Reason (XPathError property)|Reason]]</var> property.
<td>This [[Methods#Named parameters|name required]] parameter is an <var>[[#XPathErrorReason enumeration|XPathErrorReason]]</var> enumeration value which specifies the value to be assigned to the exception object's <var>[[Reason (XPathError property)|Reason]]</var> property.
The <var>Reason parameter</var> is '''not''' optional.</td></tr>
The <var>Reason</var> parameter is '''not''' optional.</td></tr>


<tr><th><var>Description</var></th>
<tr><th><var>Description</var></th>
Line 113: Line 111:
====XPathErrorReason enumeration====
====XPathErrorReason enumeration====
An <var>XPathErrorReason</var> [[Enumerations|enumeration]] may have one of the following values:
An <var>XPathErrorReason</var> [[Enumerations|enumeration]] may have one of the following values:
<table class="optionTable">
<table class="thJustBold">
<tr><th>SyntaxError</th>
<tr><th>SyntaxError</th>
<td>A violation of the syntax of an XPath expression.</td></tr>
<td>A violation of the syntax of an XPath expression.</td></tr>
Line 122: Line 120:
</table>
</table>


'''Note:''' As with all enumerations, the <var>ToString</var> method implicitly converts an enumeration value to a character string whose value is the name of the enumeration value. For more information about methods available to all enumerations, see [[Enumerations#Common enumeration methods|"Common enumeration methods"]].
<p class="note">'''Note:''' As with all enumerations, the <var>ToString</var> method implicitly converts an enumeration value to a character string whose value is the name of the enumeration value. For more information about methods available to all enumerations, see [[Enumerations#Common enumeration methods|Common enumeration methods]].</p>


[[Category:System exception classes]]
[[Category:System exception classes]]

Latest revision as of 21:59, 18 November 2014

An XPathError exception can be thrown by various methods in the XmlDoc API. It indicates an error either in the syntax of an XPath argument to the method, or in the results returned by that XPath expression. The various read-only properties of an XPathError object (which can be set by the Catch statement) provide information about the failed operation.

An example of using the XPathError exception is:

%err Object XPathError Try %d:Print('a b c') Catch XPathError To %err PrintText {~} = {%err:Reason} PrintText {~} = {%err:Description} PrintText {~} = {%err:CharacterPosition} End Try

Since the expression (a b c) in the above invocation of the Print method is not a valid XPath expression, the above fragment will result in the following:

%err:Reason = SyntaxError %err:Description = Expect "/" for new step or "[" for predicate %err:CharacterPosition = 3

This class is new in version 7.8 of the Sirius Mods.


The XPathError methods

The following are the available XPathError class methods.

MethodDescription
CharacterPositionPosition of character at of before which the error occurred
DescriptionBrief description of the exception
NewCreate a new XPathError object
ReasonEnumerated cause of the exception

The methods in the class are described in the subsections that follow. In addition:


CharacterPosition property

Position of character at of before which the error occurred (XPathError class)

[Introduced in Sirius Mods 7.8]

Syntax

%number = xPathError:CharacterPosition

Syntax terms

%number The position of the character at which the exception was thrown.
xPathError An XPathError object.


Description property

Brief description of the exception (XPathError class)

[Introduced in Sirius Mods 7.8]

Syntax

%string = xPathError:Description

Syntax terms

%string A string to receive the description of the exception.
xPathError An XPathError object.


New constructor

Create a new XPathError object (XPathError class)

[Introduced in Sirius Mods 7.8]

Each argument to New sets the value of the corresponding property of the newly constructed XPathError object.

Syntax

%xPathError = [%(XPathError):]New( Reason= xPathErrorReason, - [Description= string], - [CharacterPosition= number])

Syntax terms

%xPathError A reference to an instance of an XPathError object.
[%(XPathError):] The class name in parentheses denotes a Constructor.
Reason This name required parameter is an XPathErrorReason enumeration value which specifies the value to be assigned to the exception object's Reason property. The Reason parameter is not optional.
Description This optional, name required, parameter specifies the string value (string) to be assigned to the object's Description property.
CharacterPosition This optional, name required, parameter specifies the numeric value (number) to be assigned to the object's CharacterPosition property.


Reason property

Enumerated cause of the exception (XPathError class)

[Introduced in Sirius Mods 7.8]

Syntax

%xPathErrorReason = xPathError:Reason

Syntax terms

%xPathErrorReason This XPathErrorReason enumeration value (see below) describes the reason for the translation failure.
xPathError An XPathError object.

XPathErrorReason enumeration

An XPathErrorReason enumeration may have one of the following values:

SyntaxError A violation of the syntax of an XPath expression.
EmptyResult No nodes are matched by the XPath expression, and the method requires at least one matching node.

Note: As with all enumerations, the ToString method implicitly converts an enumeration value to a character string whose value is the name of the enumeration value. For more information about methods available to all enumerations, see Common enumeration methods.