Changes between Version 8 and Version 9 of XML/SAX


Ignore:
Timestamp:
Jan 28, 2011, 1:09:12 PM (11 years ago)
Author:
vadim.godunko
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • XML/SAX

    v8 v9  
    5151
    5252{{{
     53------------------------------------------------------------------------------
     54--  This is example of usage of XML Writer to generate XML files from
     55--  application. It generates initial part of XMPP stream.
     56------------------------------------------------------------------------------
    5357with Ada.Wide_Wide_Text_IO;
    5458
     
    5761with XML.SAX.Pretty_Writers;
    5862
    59 procedure SAX_Writer_Example is
     63procedure SAX_Writer is
    6064
    6165   use League.Strings;
    62    
     66
    6367   function "+" (Item : Wide_Wide_String) return Universal_String
    6468     renames To_Universal_String;
    65    
    66    Lang_Attribute      : constant Universal_String := +"xml:lang";
     69
     70   XML_URI             : constant Universal_String
     71     := +"http://www.w3.org/XML/1998/namespace";
     72   Lang_Attribute      : constant Universal_String := +"lang";
    6773   Stream_URI          : constant Universal_String
    6874     := +"http://etherx.jabber.org/streams";
     
    7884   Compression_Element : constant Universal_String := +"compression";
    7985   Method_Element      : constant Universal_String := +"method";
    80    
     86
    8187   Writer     : XML.SAX.Pretty_Writers.SAX_Pretty_Writer;
    8288   Attributes : XML.SAX.Attributes.SAX_Attributes;
    83    
     89
    8490begin
    8591   Writer.Start_Document;
    8692   Writer.Start_Prefix_Mapping (Namespace_URI => Client_URI);
    87    Writer.Start_Prefix_Mapping 
     93   Writer.Start_Prefix_Mapping
    8894     (Namespace_URI => Stream_URI, Prefix => Stream_Prefix);
    8995
    9096   --  Open stream element
    91    
     97
    9298   Attributes.Set_Value
    9399     (Qualified_Name => Id_Attribute, Value => +"656571601");
    94    Attributes.Set_Value 
     100   Attributes.Set_Value
    95101     (Qualified_Name => From_Attribute, Value => +"jabber.ru");
    96102   Attributes.Set_Value (Qualified_Name => Version_Attribute, Value => +"1.0");
    97    Attributes.Set_Value (Qualified_Name => Lang_Attribute, Value => +"ru");
     103   Attributes.Set_Value
     104     (Namespace_URI => XML_URI, Local_Name => Lang_Attribute, Value => +"ru");
    98105   Writer.Start_Element
    99      (Namespace_URI => Stream_URI, 
    100       Local_Name    => Stream_Element, 
     106     (Namespace_URI => Stream_URI,
     107      Local_Name    => Stream_Element,
    101108      Attributes    => Attributes);
    102    
     109
    103110   --  Open features element
    104    
     111
    105112   Writer.Start_Element
    106113     (Namespace_URI => Stream_URI, Local_Name => Features_Element);
    107    
     114
    108115   --  Open compression element
    109    
     116
    110117   Writer.Start_Prefix_Mapping (Namespace_URI => Compression_URI);
    111118   Writer.Start_Element
    112119     (Namespace_URI => Compression_URI, Local_Name => Compression_Element);
    113    
     120
    114121   --  Output method
    115122
     
    119126   Writer.End_Element
    120127     (Namespace_URI => Compression_URI, Local_Name => Method_Element);
    121    
     128
    122129   --  Close compression element
    123    
     130
    124131   Writer.End_Element
    125132     (Namespace_URI => Compression_URI, Local_Name => Compression_Element);
    126133   Writer.End_Prefix_Mapping;
    127    
     134
    128135   --  Close features element
    129    
     136
    130137   Writer.End_Element
    131138     (Namespace_URI => Stream_URI, Local_Name => Features_Element);
    132    
     139
    133140   --  Close stream element
    134    
     141
    135142   Writer.End_Element
    136143     (Namespace_URI => Stream_URI, Local_Name => Stream_Element);
     
    138145   Writer.End_Prefix_Mapping;
    139146   Writer.End_Document;
    140    
     147
    141148   Ada.Wide_Wide_Text_IO.Put_Line (Writer.Text.To_Wide_Wide_String);
    142 end SAX_Writer_Example;
     149end SAX_Writer;
    143150}}}
    144151