Reason (XmlParseError property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
Line 1: Line 1:
 
{{Template:XmlParseError:Reason subtitle}}
<span class="pageSubtitle"><section begin=dpl_desc/>XmlParseErrorReason enumeration value indicating the type of the error causing the exception<section end=dpl_desc/></span>
[[Category:XmlParseError methods|Reason property]]
<p>
Reason is a member of the [[XmlParseError class]].
</p>


==Syntax==
==Syntax==
<p class="syntax">%reason = %xmlParseErr:Reason
{{Template:XmlParseError:Reason syntax}}
</p>
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table class="syntaxTable">
Line 18: Line 12:


</td></tr></table>
</td></tr></table>
==Usage Notes==
==Usage notes==
<ul>
<ul>
<li>An XmlParseErrorReason enumeration may have one of the following values,
<li>An XmlParseErrorReason enumeration may have one of the following values,
Line 47: Line 41:
to demonstrate the XmlParseError exception output:
to demonstrate the XmlParseError exception output:
<p class="code"> Try
<p class="code"> Try
     PrintText {~}: {%d:LoadXml(&'italic(input-string))}
     PrintText {~}: {%d:LoadXml(&amp;'italic(input-string))}
  Catch XmlParseError to %err
  Catch XmlParseError to %err
     Print ' '
     Print ' '
Line 77: Line 71:
</p>
</p>


<p class="code"> '''%d:LoadXml('<a>&amp;#x2122;</a>':U)'''
<p class="code"> '''%d:LoadXml('<a>&amp;amp;#x2122;</a>':U)'''
  Error Reason: UntranslatableUnicode
  Error Reason: UntranslatableUnicode
  Error Description: XML doc parse error: invalid Unicode
  Error Description: XML doc parse error: invalid Unicode
Line 133: Line 127:
   - - -
   - - -
</p>
</p>
==See also==
{{Template:XmlParseError:Reason footer}}

Revision as of 20:42, 25 March 2011

Enumerated cause of the exception (XmlParseError class)

Syntax

%xmlParseErrorReason = xmlParseError:Reason

Syntax terms

%reason This XmlParseErrorReason enumeration value describes the parsing error.
%xmlParseErr A reference to an instance of an XmlParseError object.

Usage notes

  • An XmlParseErrorReason enumeration may have one of the following values, each of which is demonstrated in the example 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.

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(&'italic(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

These are the results:

%d:LoadXml('<a>'): 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: - - -

%d:LoadXml('<' With 'FF':X With '>') 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 - - -

%d:LoadXml('<a>&amp;#x2122;</a>':U) 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 - - -

%d:LoadXml('FEFF003C33':X) 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 - - -

%d:LoadXml('FEFFD800':X) 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 - - -

%d:LoadXml('C181':X) 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 - - -

%d:LoadXml('FF818256':X) 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 - - -

%d:LoadXml('EDA080':X) 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 - - -

See also