-- $Date: 2004/01/28 05:10:10 $
-- $Revision: 1.9 $
-- $Author: jcrocholl $

with Ada.Tags;

with Writers; use Writers;
with Indent_Writers; use Indent_Writers;

-- Light-weight XML output file writers.
package XML_Writers is

   -- Light-weight XML output file writer.
   type XML_Writer is
     new Indent_Writer with null record;

   -- Type for instance variables.
   type XML_Writer_Access is access XML_Writer;

   -------------------
   -- Creating writers
   -------------------

   -- Create an XML writer for current output (stdout).
   function Current_Output
     return XML_Writer_Access-- The newly created XML writer instance.

   -- Create an XML writer for file output.
   function Create
     (Filename : in String)    -- Open this file.
     return XML_Writer_Access-- The newly created XML writer instance.

   -- Close an XML writer's output file.
   procedure Close
     (This : in out XML_Writer_Access); -- Close this writer.

   ---------------
   -- Writing tags
   ---------------

   -- Write '<' and one word.
   procedure Start_Tag
     (This : access XML_Writer-- XML writer instance.
      Name : in String);        -- The tag name.

   -- Write '>', possibly after extras like '?'.
   procedure Close_Tag
     (This  : access XML_Writer-- XML writer instance.
      Extra : in String := "");  -- Write extras before closing '>'.

   -- Start and close tag.
   procedure Write_Tag
     (This : access XML_Writer-- XML writer instance.
      Name : in String);        -- The tag name.

   ---------------------
   -- Writing attributes
   ---------------------

   -- Write whitespace, then write one word.
   procedure Write_Attribute_Name
     (This : access XML_Writer-- XML writer instance.
      Name : in String);        -- The attribute name.

   -- Write '=', then write one string.
   procedure Write_Attribute_Value
     (This  : access XML_Writer-- XML writer instance.
      Value : in String);        -- The attribute value without quotes.

   -- Write attribute name and value.
   procedure Write_Attribute
     (This  : access XML_Writer-- XML writer instance.
      Name  : in String;         -- The attribute name.
      Value : in String);        -- The attribute value without quotes.

   ---------------
   -- Writing data
   ---------------

   -- Write characters to output.
   procedure Write_Data
     (This : access XML_Writer-- XML writer instance.
      Data : in String);        -- Write this data.

   -------------------
   -- Writing elements
   -------------------

   -- Write an element start tag.
   procedure Start_Element
     (This : access XML_Writer-- XML writer instance.
      Name : in String);        -- Name of the element.

   -- Write an element close tag.
   procedure Close_Element
     (This : access XML_Writer-- XML writer instance.
      Name : in String);        -- Name of the element.

   -- Write an empty element tag.
   procedure Write_Element
     (This : access XML_Writer-- XML writer instance.
      Name : in String);        -- Name of the element.

   -- Write an element start tag, some data, an element close tag.
   procedure Write_Element
     (This : access XML_Writer-- XML writer instance.
      Name : in String;         -- Name of the element.
      Data : in String);        -- Write this data.

   --------------------------------------
   -- Writing elements with one attribute
   --------------------------------------

   -- Write an element start tag.
   procedure Start_Element
     (This  : access XML_Writer-- XML writer instance.
      Name  : in String;         -- Name of the element.
      Attr  : in String;         -- Name of attribute.
      Value : in String);        -- Value of attribute.

   -- Write an empty element tag with one attribute.
   procedure Write_Element
     (This  : access XML_Writer-- XML writer instance.
      Name  : in String;         -- Name of the element.
      Attr  : in String;         -- Name of attribute.
      Value : in String);        -- Value of attribute.

   -- Write an element start tag, some data, an element close tag.
   procedure Write_Element
     (This  : access XML_Writer-- XML writer instance.
      Name  : in String;         -- Name of the element.
      Attr  : in String;         -- Name of attribute.
      Value : in String;         -- Value of attribute.
      Data  : in String);        -- Write this data.

end XML_Writers;