1-- 2-- Copyright (C) 2017, AdaCore 3-- 4 5with Unicode.CES; use Unicode.CES; 6with Sax.Attributes; use Sax.Attributes; 7with Ada.Text_IO; use Ada.Text_IO; 8 9package body SaxExample is 10 11 procedure Start_Element 12 (Handler : in out Reader; 13 Namespace_URI : Unicode.CES.Byte_Sequence := ""; 14 Local_Name : Unicode.CES.Byte_Sequence := ""; 15 Qname : Unicode.CES.Byte_Sequence := ""; 16 Atts : Sax.Attributes.Attributes'Class) 17 is 18 begin 19 Handler.Current_Pref := Null_Unbounded_String; 20 Handler.Current_Value := Null_Unbounded_String; 21 22 if Local_Name = "pref" then 23 Handler.Current_Pref := 24 To_Unbounded_String (Get_Value (Atts, "name")); 25 end if; 26 end Start_Element; 27 28 procedure Characters 29 (Handler : in out Reader; 30 Ch : Unicode.CES.Byte_Sequence) is 31 begin 32 if Handler.Current_Pref /= Null_Unbounded_String then 33 Handler.Current_Value := Handler.Current_Value & Ch; 34 end if; 35 end Characters; 36 37 procedure End_Element 38 (Handler : in out Reader; 39 Namespace_URI : Unicode.CES.Byte_Sequence := ""; 40 Local_Name : Unicode.CES.Byte_Sequence := ""; 41 Qname : Unicode.CES.Byte_Sequence := "") 42 is 43 begin 44 if Local_Name = "pref" then 45 Put_Line ("Value for """ & To_String (Handler.Current_Pref) 46 & """ is " & To_String (Handler.Current_Value)); 47 end if; 48 end End_Element; 49 50end SaxExample; 51