From: Emmanuel S. [ES] <ma...@ei...> - 2005-05-18 02:31:34
|
Hi, I have the following XML document: (1) <doc>™</doc> which I read it to get a XM_DOCUMENT, one of the element is a XM_CHARACTER_DATA with a character whose code is 153. So far so good. When I use the XM_FORMATTER to get a string out of my XM_DOCUMENT, I get back (2) <doc>?</doc> where `?' is on my OS the character whose code is 153. Unfortunately trying to parse (2) with the XM_EIFFEL_PARSER causes an error while reading `?'. The error simply says `parser error'. Is this a bug in the parser? Is (2) a valid XML file? In case it is invalid XML, I looked at XM_PRETTY_PRINTER_FILTER and saw the following: is_escaped (a_char: INTEGER): BOOLEAN is -- Is this an escapable character? do Result := a_char = Lt_char.code or a_char = Gt_char.code or a_char = Amp_char.code end escaped_char (a_char: INTEGER): STRING is -- Escape char. require is_escaped: is_escaped (a_char) do if a_char = Lt_char.code then Result := Lt_entity elseif a_char = Gt_char.code then Result := Gt_entity elseif a_char = Amp_char.code then Result := Amp_entity elseif a_char = Quot_char.code then Result := Quot_entity else Result := STRING_.concat ("&#", a_char.out) Result := STRING_.concat (Result, ";") end end Looks strange that `escaped_char' handles more possibilities than expected by its precondition. Anyway, I've modified `is_escaped' as below: is_escaped (a_char: INTEGER): BOOLEAN is -- Is this an escapable character? do Result := a_char = Lt_char.code or a_char = Gt_char.code or a_char = Amp_char.code or a_char >= 128 end and it works definitely better, but I'm not sure this is correct. Thanks for your help, Manu ------------------------------------------------------------------------ Eiffel Software 805-685-1006 http://www.eiffel.com Customer support: http://support.eiffel.com Product information: mailto:in...@ei... User group: http://groups.eiffel.com/join ------------------------------------------------------------------------ |