------------------------------------------------------------------------------ -- XML/Ada - An XML suite for Ada95 -- -- -- -- Copyright (C) 2001-2012, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- . -- -- -- ------------------------------------------------------------------------------ pragma ada_05; with Sax.Readers; use Sax.Readers; with Sax.Exceptions; with Sax.Symbols; with Sax.Utils; with Unicode.CES; with DOM.Core; use DOM.Core; package DOM.Readers is type tree_reader is new sax_reader with private; type tree_reader_access is access all tree_reader'class; -- Special SAX Reader that creates a DOM tree in its callbacks. -- Note that in case of a fatal error, it is your responsability to -- free the tree, since it is left in the state it was when the error -- was raised (for post-death analysis, if required). function Get_Tree (Read : tree_reader) return document; procedure Free (Read : in out tree_reader); -- Free the memory associated with the reader, in particular the tree procedure Set_Warnings_As_Errors (Read : in out tree_reader; Warnings_As_Error : Boolean); -- iF Warnings_As_Error is True, then all warnings will raise a fatal error -- exception, just like a fatal error. Otherwise, warnings are ignored. overriding procedure Start_Document (Handler : in out tree_reader); overriding procedure Start_Element (Handler : in out tree_reader; NS : Sax.Utils.xml_ns; Local_Name : Sax.Symbols.symbol; Atts : Sax.Readers.sax_attribute_list); overriding procedure End_Element (Handler : in out tree_reader; NS : Sax.Utils.xml_ns; Local_Name : Sax.Symbols.symbol); overriding procedure Characters (Handler : in out tree_reader; Ch : Unicode.CES.byte_sequence); overriding procedure Ignorable_Whitespace (Handler : in out tree_reader; Ch : Unicode.CES.byte_sequence); overriding procedure Processing_Instruction (Handler : in out tree_reader; Target : Unicode.CES.byte_sequence; Data : Unicode.CES.byte_sequence); overriding procedure Start_DTD (Handler : in out tree_reader; Name : Unicode.CES.byte_sequence; Public_Id : Unicode.CES.byte_sequence := ""; System_Id : Unicode.CES.byte_sequence := ""); overriding procedure End_DTD (Handler : in out tree_reader); overriding procedure Comment (Handler : in out tree_reader; Comment : Unicode.CES.byte_sequence); overriding procedure Error (Handler : in out tree_reader; Except : Sax.Exceptions.sax_parse_exception'class); overriding procedure Warning (Handler : in out tree_reader; Except : Sax.Exceptions.sax_parse_exception'class); -- See inherited documentation private type tree_reader is new reader with record Tree : document; Current_Node : node; Internal_Encoding : Unicode.CES.encoding_scheme; In_DTD : Boolean := False; Warnings_As_Error : Boolean := False; end record; end DOM.Readers;