-- $Date: 2004/02/14 06:22:42 $
-- $Revision: 1.3 $
-- $Author: jcrocholl $

with Readers; use Readers;
with Token_Readers; use Token_Readers;

package body Notations.Articulations.MusicXML is

   -- Read an articulation from an XML reader;
   function Read_Articulation
     (XML : access XML_Reader-- Use this XML reader.
     return Notation_Access    -- The newly created articulation.
   is
      Articulation : Articulation_Enum;
      Placement    : Placement_Enum := Default;
   begin
      Articulation := To_Articulation_Enum(Get_Context(XML));
      while not End_Of_Tag(XML) loop
         Read_Attribute_Name(XML);
         if Found(XML, "placement") then
            Read_Attribute_Value(XML);
            Placement := To_Placement_Enum(Get_Token(XML));
         else
            XML_Expect_Error(XML, "", "placement");
         end if;
      end loop;
      Exit_Tag(XML);

      return Notation_Access(Create(Articulation, Placement));
   end Read_Articulation;

   -- Write articulation data to an XML writer.
   procedure Write_Articulation
     (XML  : access XML_Writer;   -- Use this XML writer.
      This : access Articulation-- Write this articulation.
   is
   begin
      Write_Element(XML, To_XML(Get_Name(This)'Img),
        "placement", To_XML(Get_Placement(This)'Img));
   end Write_Articulation;

end Notations.Articulations.MusicXML;