lace_xml_0.1.0_b6aa904a/source/xml.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
private
with
     ada.Strings.unbounded,
     ada.Containers.vectors;


package XML
--
-- Provides simple XML reader/writer support.
--
-- Heavily based on Chip Richards Ada XML packages.
--
is

   --- Attribute type
   --

   type Attribute_t     is tagged private;
   type Attributes_t    is array (Positive range <>) of aliased Attribute_t;

   type Attributes_view is access all Attributes_t;


   function Name  (Self : in Attribute_t) return String;
   function Value (Self : in Attribute_t) return String;



   --- Element type
   --

   type Element  is tagged private;
   type Elements is array (Positive range <>) of access Element;



   -- Construction
   --

   function to_XML (Filename : in String) return Element;
   --
   -- Parses 'Filename' and returns the root node Element of the parsed XML tree.



   -- Attributes
   --

   function  Name       (Self : in     Element) return String;
   function  Attributes (Self : in     Element) return Attributes_t;
   function  Data       (Self : in     Element) return String;

   function  Attribute  (Self : in     Element;   Named : in String) return access Attribute_t'Class;
   --
   -- Returns null if the named attribute does not exist.


   -- Hierachy
   --

   function  Parent     (Self : in     Element) return access Element;
   function  Children   (Self : in     Element) return Elements;


   function  Child      (Self : in     Element;   Named : in String) return access Element;
   --
   -- Returns null if the named child does not exist.


   function  Children   (Self : in     Element;   Named : in String) return Elements;

   procedure add_Child  (Self : in out Element;   the_Child : access Element);





private

   use ada.Strings.unbounded;


   type Attribute_t is tagged
      record
         Name  : unbounded_String;
         Value : unbounded_String;
      end record;



   type Element_view    is access all Element;

   package element_Vectors is new ada.containers.Vectors (Positive, Element_view);
   subtype element_Vector  is element_vectors.Vector;


   type Element is tagged
      record
         Name       : unbounded_String;
         Attributes : Attributes_view;
         Data       : unbounded_String;

         Parent     : Element_view;
         Children   : element_Vector;
      end record;

end XML;