Hosted by
 |
with Readers; use Readers;
with Token_Readers; use Token_Readers;
with Encodings.MusicXML; use Encodings.MusicXML;
with String_String_Hash_Tables; use String_String_Hash_Tables;
package body Identifications.MusicXML is
procedure Read_Creator
(XML : access XML_Reader;
This : access Identification) is
begin
Assert_Attribute_Name(XML, "type");
Read_Attribute_Value(XML);
Add_Creator(This, Get_Token(XML), Read_Data(XML));
Exit_Tag(XML);
Assert_Tag(XML, "/creator");
end Read_Creator;
procedure Write_Creators
(XML : access XML_Writer;
This : access Hash_Table)
is
Index : Natural := 0;
begin
loop
Next(This, Index);
exit when Index = 0;
Write_Element(XML, "creator",
"type", Get_Key(This, Index),
Get_Item(This, Index));
end loop;
end Write_Creators;
function Read_Identification
(XML : access XML_Reader)
return Identification_Access
is
Result : Identification_Access := Create;
begin
while Descend(XML) loop
if not Found(XML, "creator") then
Exit_Tag(XML);
end if;
if Found(XML, "creator") then
Read_Creator(XML, Result);
elsif Found(XML, "encoding") then
Set_Encoding(Result, Read_Encoding(XML));
elsif Found(XML, "rights") then
Set_Rights(Result, Read_Data(XML));
Exit_Element(XML);
elsif Found(XML, "source") then
Set_Source(Result, Read_Data(XML));
Exit_Element(XML);
else
XML_Expect_Error(XML, "/identification",
"encoding" / "rights" / "source");
end if;
end loop;
Exit_Tag(XML);
return Result;
end Read_Identification;
procedure Write_Identification
(XML : access XML_Writer;
This : access Identification)
is
begin
Start_Element(XML, "identification");
Write_Creators(XML, Get_Creators(This));
if Get_Rights(This) /= "" then
Write_Element(XML, "rights", Get_Rights(This));
end if;
if Get_Encoding(This) /= null then
Write_Encoding(XML, Get_Encoding(This));
end if;
Close_Element(XML, "identification");
end Write_Identification;
end Identifications.MusicXML;
|