Changes between Version 11 and Version 12 of XML/SAX


Ignore:
Timestamp:
Apr 4, 2011, 5:25:51 PM (10 years ago)
Author:
vadim.godunko
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • XML/SAX

    v11 v12  
    33= Simple API for XML =
    44
    5 Current development version of Matreshka includes implementation of SAX to process XML files.
    6 
    7 == Build procedure ==
    8 
    9  1. Download source code package or checkout source code from repository (be ready to download approximately 95M) svn://adaforge.qtada.com/matreshka/trunk/matreshka
    10  2. Run make in root directory to configure system and build libraries.
    11  3. Enter examples/sax_events_printer directory.
    12  4. Run gprbuild to build demo program.
    13 
    14 To play with demo program run
    15 
    16 {{{
    17 ./sax_events_printer <file.xml>
    18 }}}
     5Matreshka provides SAX-style reader and writer for XML 1.0/1.1. Corresponding Namespaces in XML specifications are supported also.
     6
     7Matreshka's SAX reader can use Ada streams, strings, files and sockets as input source. It supports incremental parsing of streams (when control returns to the caller after processing of the portion of stream). It approximately 30% faster then !XmlAda's reader and has the same performance as Qt's reader.
     8
     9API uses Universal_String to represent all text data which hides complexity of encoding handling from application. SAX event handlers has additional 'in out' parameter to control future processing of the document/stream and additional subprogram Error_String to report application errors in centralized manner. This provides more control over document/stream processing, improves application's code readability, and helps to develop localized applications. Reporting of application level errors by exceptions mechanism is also supported.
     10
     11SAX writer allows to generate XML documents and streams from the application. It supports strings as output destination now. It supports incremental generation of XML streams also.
    1912
    2013== Packages Overview ==
     
    4841== Examples ==
    4942
     43=== SAX Reader Example ===
     44
     45Example of use of SAX Reader is present in examples/sax_event_printer directory. This program reads XML document from the specified file and outputs SAX events from all handlers.
     46
     47{{{
     48with Ada.Command_Line;
     49
     50with League.Strings;
     51with XML.SAX.Input_Sources.Streams.Files;
     52with XML.SAX.Simple_Readers;
     53
     54with Events_Printers;
     55
     56procedure Sax_Events_Printer is
     57   Source  : aliased XML.SAX.Input_Sources.Streams.Files.File_Input_Source;
     58   Reader  : aliased XML.SAX.Simple_Readers.SAX_Simple_Reader;
     59   Handler : aliased Events_Printers.Events_Printer;
     60
     61begin
     62   XML.SAX.Simple_Readers.Put_Line := Put_Line'Access;
     63   Reader.Set_Content_Handler (Handler'Unchecked_Access);
     64   Reader.Set_Declaration_Handler (Handler'Unchecked_Access);
     65   Reader.Set_DTD_Handler (Handler'Unchecked_Access);
     66   Reader.Set_Entity_Resolver (Handler'Unchecked_Access);
     67   Reader.Set_Error_Handler (Handler'Unchecked_Access);
     68   Reader.Set_Lexical_Handler (Handler'Unchecked_Access);
     69
     70   Source.Open (Ada.Command_Line.Argument (1));
     71   Reader.Parse (Source'Access);
     72end Sax_Events_Printer;
     73}}}
     74
     75To build application:
     76
     77 1. Enter examples/sax_events_printer directory.
     78 1. Run gprbuild to build demo program.
     79
     80To play with demo program run
     81
     82{{{
     83./sax_events_printer <file.xml>
     84}}}
     85
    5086=== SAX Writer Example ===
    5187