Reason (XmlParseError property): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (match syntax table to syntax template, tags and edits)
Line 1: Line 1:
{{Template:XmlParseError:Reason subtitle}}
{{Template:XmlParseError:Reason subtitle}}
This readOnly property returns an <var>XmlParseErrorReason</var> enumeration value that describes the error that caused the <var>[[XmlParseError_class|XmlParseError]]</var>exception.


==Syntax==
==Syntax==
Line 6: Line 7:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%reason</th>
<tr><th>%reason</th>
<td>This XmlParseErrorReason enumeration value describes the parsing error.
<td>This <var>XmlParseErrorReason</var> enumeration value describes the parsing error.
</td></tr>
</td></tr>
<tr><th>%xmlParseErr</th>
<tr><th>xmlParsError</th>
<td>A reference to an instance of an XmlParseError object.
<td>A reference to an instance of a <var>[[XmlParseError_class|XmlParseError]]</var> object.
</td></tr>
</td></tr>
</table>
</table>
Line 15: Line 16:
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>An XmlParseErrorReason enumeration may have one of the following values,
<li>An <var>XmlParseErrorReason</var> enumeration may have one of the following values, each of which is demonstrated in the [[#Example|examples]] below.
each of which is demonstrated in the [[#Example|example below]].
<dl>
<dl>
<dt>InvalidUnicodeCharacter
<dt><var>InvalidUnicodeCharacter</var>
<dd>The Unicode input contains an invalid character.
<dd>The Unicode input contains an invalid character.
<dt>InvalidUTF8Encoding
<dt><var>InvalidUTF8Encoding</var>
<dd>The input UTF8 stream is invalid.
<dd>The input UTF8 stream is invalid.
<dt>InvalidUTF16Encoding
<dt><var>InvalidUTF16Encoding</var>
<dd>The input UTF16 stream is invalid.
<dd>The input UTF16 stream is invalid.
<dt>SyntaxError
<dt><var>SyntaxError</var>
<dd>A violation of the syntax of an XML document.
<dd>A violation of the syntax of an XML document.
<dt>UntranslatableEBCDIC
<dt><var>UntranslatableEBCDIC</var>
<dd>The EBCDIC input contains a character that is not translatable to Unicode.
<dd>The EBCDIC input contains a character that is not translatable to Unicode.
<dt>UntranslatableISOn
<dt><var>UntranslatableISOn</var>
<dd>The ISO-8859-n input contains a character that is not translatable to Unicode.
<dd>The ISO-8859-n input contains a character that is not translatable to Unicode.
<dt>UntranslatableUnicode
<dt><var>UntranslatableUnicode</var>
<dd>The Unicode input contains a character that is not translatable to EBCDIC.
<dd>The Unicode input contains a character that is not translatable to EBCDIC.
This exception can be avoided using the <code>AllowUntranslatable</code>
This exception can be avoided using the <code>AllowUntranslatable</code>
Line 36: Line 36:
</dl>
</dl>
</ul>
</ul>
==Example==
==Example==
 
<ol><li>
The following template is used to apply the LoadXml deserialization method
The following template is used to apply the <var>[[LoadXml_(XmlDoc/XmlNode_function)|LoadXml]]</var> deserialization method to a series of test ''input-string'' values to demonstrate the <var>XmlParseError</var> exception output:
to a series of test ''input-string'' values
<p class="code">   [[try]]
to demonstrate the XmlParseError exception output:
      [[PrintText statement|printText]] {~}: {%d:LoadXml(&amp;'italic(input-string))}
<p class="code"> Try
  [[catch]] XmlParseError to %err
    PrintText {~}: {%d:LoadXml(&amp;'italic(input-string))}
      print ' '
Catch XmlParseError to %err
      print 'Error Reason:' And %err:Reason:ToString
    Print ' '
      print 'Error Description:' And %err:Description
    Print 'Error Reason:' And %err:Reason:ToString
      print 'Error Character Position:' And %err:CharacterPosition
    Print 'Error Description:' And %err:Description
      print 'Error Input Hex Value:' And %err:InputHexValue
    Print 'Error Character Position:' And %err:CharacterPosition
      print ' - - -'
    Print 'Error Input Hex Value:' And %err:InputHexValue
  end try
    Print ' - - -'
End Try
</p>
</p>
 
<ul><li>When called with:
These are the results:
<p class="code"> '''%d:LoadXml('<a>'):'''
<p class="code"> '''%d:LoadXml('<a>'):'''
</p>
The results are:
<p class="output">
  Error Reason: SyntaxError
  Error Reason: SyntaxError
  Error Description: XML doc parse error: missing ETag for top
  Error Description: XML doc parse error: missing ETag for top
Line 62: Line 63:
   - - -
   - - -
</p>
</p>
 
<li>When called with:
<p class="code"> '''%d:LoadXml('<' With 'FF':X With '>')'''
<p class="code"> '''%d:LoadXml('<' With 'FF':X With '>')'''
</p>
The results are:
<p class="output">
  Error Reason: UntranslatableEBCDIC
  Error Reason: UntranslatableEBCDIC
  Error Description: XML doc parse error: EBCDIC character not
  Error Description: XML doc parse error: EBCDIC character not
Line 71: Line 75:
   - - -
   - - -
</p>
</p>
 
<li>When called with:
<p class="code"> '''%d:LoadXml('<a>&amp;amp;#x2122;</a>':U)'''
<p class="code"> '''%d:LoadXml('<a>&amp;amp;#x2122;</a>':U)'''
</p>
The results are:
<p class="output">
  Error Reason: UntranslatableUnicode
  Error Reason: UntranslatableUnicode
  Error Description: XML doc parse error: invalid Unicode
  Error Description: XML doc parse error: invalid Unicode
Line 81: Line 88:
   - - -
   - - -
</p>
</p>
 
<li>When called with:
<p class="code"> '''%d:LoadXml('FEFF003C33':X)'''
<p class="code"> '''%d:LoadXml('FEFF003C33':X)'''
</p>
The results are:
<p class="output">
  Error Reason: InvalidUTF16Encoding
  Error Reason: InvalidUTF16Encoding
  Error Description: XML doc parse error: expecting additional
  Error Description: XML doc parse error: expecting additional
Line 91: Line 101:
   - - -
   - - -
</p>
</p>
 
<li>When called with:
<p class="code"> '''%d:LoadXml('FEFFD800':X)'''
<p class="code"> '''%d:LoadXml('FEFFD800':X)'''
</p>
The results are:
<p class="output">
  Error Reason: InvalidUnicodeCharacter
  Error Reason: InvalidUnicodeCharacter
  Error Description: XML doc parse error: surrogate point in
  Error Description: XML doc parse error: surrogate point in
Line 100: Line 113:
   - - -
   - - -
</p>
</p>
 
<li>When called with:
<p class="code"> '''%d:LoadXml('C181':X)'''
<p class="code"> '''%d:LoadXml('C181':X)'''
</p>
The results are:
<p class="output">
  Error Reason: InvalidUTF8Encoding
  Error Reason: InvalidUTF8Encoding
  Error Description: XML doc parse error: byte 1 of 2 too
  Error Description: XML doc parse error: byte 1 of 2 too
Line 109: Line 125:
   - - -
   - - -
</p>
</p>
 
<li>When called with:
<p class="code"> '''%d:LoadXml('FF818256':X)'''
<p class="code"> '''%d:LoadXml('FF818256':X)'''
</p>
The results are:
<p class="output">
  Error Reason: InvalidUTF8Encoding
  Error Reason: InvalidUTF8Encoding
  Error Description: XML doc parse error: attempt to use
  Error Description: XML doc parse error: attempt to use
Line 119: Line 138:
   - - -
   - - -
</p>
</p>
 
<li>When called with:
<p class="code"> '''%d:LoadXml('EDA080':X)'''
<p class="code"> '''%d:LoadXml('EDA080':X)'''
</p>
The results are:
<p class="output">
  Error Reason: InvalidUnicodeCharacter
  Error Reason: InvalidUnicodeCharacter
  Error Description: XML doc parse error: invalid Unicode
  Error Description: XML doc parse error: invalid Unicode
Line 127: Line 149:
  Error Input Hex Value: EDA080
  Error Input Hex Value: EDA080
   - - -
   - - -
</p>
</p></ul></ol>
 
==See also==
==See also==
{{Template:XmlParseError:Reason footer}}
{{Template:XmlParseError:Reason footer}}

Revision as of 12:16, 24 April 2011

Enumerated cause of the exception (XmlParseError class) This readOnly property returns an XmlParseErrorReason enumeration value that describes the error that caused the XmlParseErrorexception.

Syntax

%xmlParseErrorReason = xmlParseError:Reason

Syntax terms

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

Usage notes

  • 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.

Example

  1. 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

    • 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>&amp;#x2122;</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 - - -

See also