Reason (XmlParseError property): Difference between revisions

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


==Syntax==
[[Category:XmlParseError methods|Reason property]]
{{Template:XmlParseError:Reason syntax}}
===Syntax terms===
<table class="syntaxTable">
<tr><th>%reason</th>
<td>This <var>XmlParseErrorReason</var> enumeration value describes the parsing error.
</td></tr>
<tr><th>xmlParsError</th>
<td>A reference to an instance of a <var>[[XmlParseError_class|XmlParseError]]</var> object.
</td></tr>
</table>
 
==Usage notes==
<ul>
<li>An <var>XmlParseErrorReason</var> enumeration may have one of the following values, each of which is demonstrated in the [[#Example|examples]] below.
<dl>
<dt><var>InvalidUnicodeCharacter</var>
<dd>The Unicode input contains an invalid character.
<dt><var>InvalidUTF8Encoding</var>
<dd>The input UTF8 stream is invalid.
<dt><var>InvalidUTF16Encoding</var>
<dd>The input UTF16 stream is invalid.
<dt><var>SyntaxError</var>
<dd>A violation of the syntax of an XML document.
<dt><var>UntranslatableEBCDIC</var>
<dd>The EBCDIC input contains a character that is not translatable to Unicode.
<dt><var>UntranslatableISOn</var>
<dd>The ISO-8859-n input contains a character that is not translatable to Unicode.
<dt><var>UntranslatableUnicode</var>
<dd>The Unicode input contains a character that is not translatable to EBCDIC.
This exception can be avoided using the <code>AllowUntranslatable</code>
option of the deserialization method.
</dl>
</ul>
 
==Example==
<ol><li>
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:
<p class="code">  [[try]]
      [[PrintText statement|printText]] {~}: {%d:LoadXml(&amp;'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
</p>
<ul><li>When called with:
<p class="code"> '''%d:LoadXml('<a>'):'''
</p>
The results are:
<p class="output">
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:
  - - -
</p>
<li>When called with:
<p class="code"> '''%d:LoadXml('<' With 'FF':X With '>')'''
</p>
The results are:
<p class="output">
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
  - - -
</p>
<li>When called with:
<p class="code"> '''%d:LoadXml('<a>&amp;amp;#x2122;</a>':U)'''
</p>
The results are:
<p class="output">
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
  - - -
</p>
<li>When called with:
<p class="code"> '''%d:LoadXml('FEFF003C33':X)'''
</p>
The results are:
<p class="output">
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
  - - -
</p>
<li>When called with:
<p class="code"> '''%d:LoadXml('FEFFD800':X)'''
</p>
The results are:
<p class="output">
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
  - - -
</p>
<li>When called with:
<p class="code"> '''%d:LoadXml('C181':X)'''
</p>
The results are:
<p class="output">
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
  - - -
</p>
<li>When called with:
<p class="code"> '''%d:LoadXml('FF818256':X)'''
</p>
The results are:
<p class="output">
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
  - - -
</p>
<li>When called with:
<p class="code"> '''%d:LoadXml('EDA080':X)'''
</p>
The results are:
<p class="output">
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
  - - -
</p></ul></ol>
 
==See also==
{{Template:XmlParseError:Reason footer}}

Latest revision as of 20:01, 10 May 2011