XmlParseError class: Difference between revisions
mNo edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 9: | Line 9: | ||
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 | <li>[[Notation conventions for methods]] has information | ||
about the conventions followed. | about the conventions followed. | ||
<li>[[XmlParseError methods syntax | <li>[[XmlParseError methods syntax]] is a single page that contains the syntax diagrams of all the methods in the class. | ||
</ul> | </ul> | ||
Line 134: | Line 134: | ||
====XmlParseErrorReason enumeration==== | ====XmlParseErrorReason enumeration==== | ||
An <var>XmlParseErrorReason</var> [[Enumerations|enumeration]] may have one of the following values, each of which is demonstrated in the [[#Example|examples]] below. | An <var>XmlParseErrorReason</var> [[Enumerations|enumeration]] may have one of the following values, each of which is demonstrated in the [[#Example|examples]] below. | ||
<table> | <table class="thJustBold"> | ||
<tr><th>InvalidUnicodeCharacter | <tr><th>InvalidUnicodeCharacter | ||
</th><td>The Unicode input contains an invalid character.</td></tr> | </th><td>The Unicode input contains an invalid character.</td></tr> | ||
Line 159: | Line 159: | ||
===Usage notes=== | ===Usage notes=== | ||
<ul> | <ul> | ||
<li>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| | <li>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]]. | ||
</ul> | </ul> | ||
Latest revision as of 19:20, 23 July 2014
The XmlParseError exception class catches parsing errors (including syntax, translation, and encoding errors) thrown by the deserialization methods: LoadXml and WebReceive of the Janus SOAP XmlDoc API, and the ParseXml method of the HttpResponse class.
This class is available as of Sirius Mods Version 7.6.
The XmlParseError methods
The following are the available XmlParseError class methods.
Method | Description |
---|---|
CharacterPosition | Position of character at of before which the error occurred |
Description | Brief description of the exception |
InputHexValue | Hexadecimal value of bytes causing the exception |
New | Create a new XmlParseError object |
Reason | Enumerated cause of the exception |
The methods in the class are described in the subsections that follow. In addition:
- Notation conventions for methods has information about the conventions followed.
- XmlParseError methods syntax is a single page that contains the syntax diagrams of all the methods in the class.
CharacterPosition property
Position of character at of before which the error occurred (XmlParseError class)
This ReadOnly property returns a number that indicates the position within the input character stream (starting with 1) at or before which the error was detected.
Syntax
%number = xmlParseError:CharacterPosition
Syntax terms
%number | The position at or before which the error was detected. |
---|---|
xmlParsError | A reference to an instance of an XmlParseError object. |
Usage notes
- The number of bytes that constitute a character depends on the type of string that causes the exception:
- If EBCDIC, one byte corresponds to one character.
- If Unicode, two bytes correspond to one character.
- If UTF-16, two bytes correspond to one character.
- If UTF-8, the relationship between bytes and characters is variable, depending on the code points.
Description property
Brief description of the exception (XmlParseError class)
This ReadOnly property returns a string that contains a brief description of the exception.
Syntax
%string = xmlParseError:Description
Syntax terms
%string | A string to receive the description of the exception. |
---|---|
xmlParsError | A reference to an instance of a XmlParseError object. |
InputHexValue property
Hexadecimal value of bytes causing the exception (XmlParseError class)
This ReadOnly property returns a string that contains the hexadecimal representation of the bytes that caused the exception to be thrown.
InputHexvalue returns a value for all reasons except SyntaxError.
Syntax
%string = xmlParseError:InputHexValue
Syntax terms
%string | A string to receive the hexadecimal value of the bytes that caused the exception to be thrown. |
---|---|
xmlParsError | A reference to an instance of a XmlParseError object. |
New constructor
Create a new XmlParseError object (XmlParseError class)
This Constructor generates an instance of an XmlParseError exception. As shown in the syntax that follows, the New method arguments set the values of the class properties that have the corresponding names.
Each argument to New sets the value of the corresponding property of the newly constructed XmlParseError object.
Syntax
%xmlParseError = [%(XmlParseError):]New( Reason= xmlParseErrorReason, - [CharacterPosition= number], - [Description= string], - [InputHexValue= string])
Syntax terms
xmlParsError | A reference to an instance of a XmlParseError object. |
---|---|
[%(XmlParseError):] | The class name in parentheses denotes a Constructor. |
Reason | This name required parameter specifies the value to be assigned to the exception object's Reason property.
Reason settings are XmlParseErrorReason enumeration values. The Reason parameter is not optional. |
CharacterPosition | This optional, but name required, parameter specifies the numeric value (number) to be assigned to the object's CharacterPosition property. Its default value is 0. |
Description | This optional, but name required, parameter specifies the string value (string) to be assigned to the object's Description property. Its default value is a null string. |
InputHexValue | This optional, but name required, parameter specifies the string value (string) to be assigned to the object's InputHexValue property. Its default value is a null string. |
Reason property
Enumerated cause of the exception (XmlParseError class)
This ReadOnly property returns an XmlParseErrorReason enumeration value that describes the error that caused the XmlParseError exception.
Syntax
%xmlParseErrorReason = xmlParseError:Reason
Syntax terms
%xmlParseErrorReason | This XmlParseErrorReason enumeration value (see below) describes the parsing error. |
---|---|
xmlParsError | A reference to an instance of a XmlParseError object. |
XmlParseErrorReason enumeration
An XmlParseErrorReason enumeration may have one of the following values, each of which is demonstrated in the examples below.
InvalidUnicodeCharacter | The Unicode input contains an invalid character. |
---|---|
InvalidUTF8Encoding | The input UTF8 stream is invalid. |
InvalidUTF16Encoding | The input UTF16 stream is invalid. |
SyntaxError | A violation of the syntax of an XML document. |
UntranslatableEBCDIC | The EBCDIC input contains a character that is not translatable to Unicode. |
UntranslatableISOn | The ISO-8859-n input contains a character that is not translatable to Unicode. |
UntranslatableUnicode | The Unicode input contains a character that is not translatable to EBCDIC. This exception can be avoided using the AllowUntranslatable option of the deserialization method. |
Usage notes
- 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.
Example
The following template is used to apply the LoadXml deserialization method to a series of test input-string
values to demonstrate the XmlParseError exception output:
try printText {~}: {%d:LoadXml(input-string)} catch XmlParseError to %err print ' ' print 'Error Reason:' And %err:Reason:ToString print 'Error Description:' And %err:Description print 'Error Character Position:' And %err:CharacterPosition print 'Error Input Hex Value:' And %err:InputHexValue print ' - - -' end try
- When called with:
%d:LoadXml('<a>'):
The results are:
Error Reason: SyntaxError Error Description: XML doc parse error: missing ETag for top level element near or before position 4 (end of input) Error Character Position: 4 Error Input Hex Value: - - -
- When called with:
%d:LoadXml('<' With 'FF':X With '>')
The results are:
Error Reason: UntranslatableEBCDIC Error Description: XML doc parse error: EBCDIC character not translatable to Unicode near or before position 3 Error Character Position: 3 Error Input Hex Value: FF - - -
- When called with:
%d:LoadXml('<a>™</a>':U)
The results are:
Error Reason: UntranslatableUnicode Error Description: XML doc parse error: invalid Unicode character - not translatable to EBCDIC near or before position 5 Error Character Position: 5 Error Input Hex Value: 2122 - - -
- When called with:
%d:LoadXml('FEFF003C33':X)
The results are:
Error Reason: InvalidUTF16Encoding Error Description: XML doc parse error: expecting additional byte of UTF-16 encoding near or before position 2 (end of input) Error Character Position: 2 Error Input Hex Value: 33 - - -
- When called with:
%d:LoadXml('FEFFD800':X)
The results are:
Error Reason: InvalidUnicodeCharacter Error Description: XML doc parse error: surrogate point in UTF-16 input near or before position 1 Error Character Position: 1 Error Input Hex Value: D800 - - -
- When called with:
%d:LoadXml('C181':X)
The results are:
Error Reason: InvalidUTF8Encoding Error Description: XML doc parse error: byte 1 of 2 too low in UTF-8 encoding near or before position 2 Error Character Position: 2 Error Input Hex Value: C181 - - -
- When called with:
%d:LoadXml('FF818256':X)
The results are:
Error Reason: InvalidUTF8Encoding Error Description: XML doc parse error: attempt to use 4-byte UTF-8 encoding of surrogate point near or before position 2 Error Character Position: 2 Error Input Hex Value: FF - - -
- When called with:
%d:LoadXml('EDA080':X)
The results are:
Error Reason: InvalidUnicodeCharacter Error Description: XML doc parse error: invalid Unicode character (surrogate range) near or before position 2 Error Character Position: 2 Error Input Hex Value: EDA080 - - -