Files
xmlada/docs/cross/sax/saxexample.adb
Fedor Rybin 9dd5a102f3 Q605-023 add VxWorks-friendly tests
For the purpose of sanity checking xmlada on VxWorks (and possibly
other cross platforms), add cross-comilable examples, one per dom, sax
and schema, that have all xml/xsd sources embedded in the test's main.
Add new cross- and existing examples to the installation of xmlada.

Change-Id: I56848955171a3b1f16f38bc3ecd7cef253af6346
2017-06-09 11:29:30 +03:00

51 lines
1.4 KiB
Ada
Executable File

--
-- Copyright (C) 2017, AdaCore
--
with Unicode.CES; use Unicode.CES;
with Sax.Attributes; use Sax.Attributes;
with GNAT.IO; use GNAT.IO;
package body SaxExample is
procedure Start_Element
(Handler : in out Reader;
Namespace_URI : Unicode.CES.Byte_Sequence := "";
Local_Name : Unicode.CES.Byte_Sequence := "";
Qname : Unicode.CES.Byte_Sequence := "";
Atts : Sax.Attributes.Attributes'Class)
is
begin
Handler.Current_Pref := Null_Unbounded_String;
Handler.Current_Value := Null_Unbounded_String;
if Local_Name = "pref" then
Handler.Current_Pref :=
To_Unbounded_String (Get_Value (Atts, "name"));
end if;
end Start_Element;
procedure Characters
(Handler : in out Reader;
Ch : Unicode.CES.Byte_Sequence) is
begin
if Handler.Current_Pref /= Null_Unbounded_String then
Handler.Current_Value := Handler.Current_Value & Ch;
end if;
end Characters;
procedure End_Element
(Handler : in out Reader;
Namespace_URI : Unicode.CES.Byte_Sequence := "";
Local_Name : Unicode.CES.Byte_Sequence := "";
Qname : Unicode.CES.Byte_Sequence := "")
is
begin
if Local_Name = "pref" then
Put_Line ("Value for """ & To_String (Handler.Current_Pref)
& """ is " & To_String (Handler.Current_Value));
end if;
end End_Element;
end SaxExample;