Hosted by
|
with XML_Readers; use XML_Readers;
with XML_Writers; use XML_Writers;
with Writers; use Writers;
with Scores.MusicXML; use Scores.MusicXML;
package body MusicXML is
procedure Read_XML_Header
(XML : access XML_Reader) is
begin
Assert_Tag_Name(XML, "?xml");
while not End_Of_Tag(XML) loop
Read_Attribute_Name(XML);
Read_Attribute_Value(XML);
end loop;
Exit_Tag(XML);
end Read_XML_Header;
procedure Write_XML_Header
(XML : access XML_Writer) is
begin
Start_Tag(XML, "?xml");
Write_Attribute(XML, "version", "1.0");
Write_Attribute(XML, "encoding", "UTF-8");
Write_Attribute(XML, "standalone", "no");
Close_Tag(XML, "?");
New_Line(XML);
end Write_XML_Header;
procedure Read_Document_Header
(XML : access XML_Reader) is
begin
Assert_Tag_Name(XML, "!DOCTYPE");
while not End_Of_Tag(XML) loop
Read_Attribute_Name(XML);
end loop;
Exit_Tag(XML);
end Read_Document_Header;
procedure Write_Document_Header
(XML : access XML_Writer) is
begin
Start_Tag(XML, "!DOCTYPE");
Write_Attribute_Name(XML, "score-partwise");
Write_Attribute_Name(XML, "PUBLIC");
Write_Attribute_Name(XML, """-//Recordare//DTD MusicXML 1.0 Partwise//EN""");
Write_Attribute_Name(XML, """http://www.musicxml.org/dtds/partwise.dtd""");
Close_Tag(XML);
New_Line(XML);
end Write_Document_Header;
function Read
(XML : access XML_Reader)
return Score_Access is
begin
Read_XML_Header(XML);
Read_Document_Header(XML);
return Read_Score(XML);
end Read;
function Read
return Score_Access
is
XML : XML_Reader_Access;
Result : Score_Access;
begin
XML := Current_Input;
Result := Read(XML);
Close(XML);
return Result;
end Read;
function Read_File
(Filename : in String)
return Score_Access
is
XML : XML_Reader_Access;
Result : Score_Access;
begin
XML := Open(Filename);
Result := Read(XML);
Close(XML);
return Result;
end Read_File;
procedure Write
(XML : access XML_Writer;
This : access Score) is
begin
Write_XML_Header(XML);
Write_Document_Header(XML);
Write_Score_Partwise(XML, This);
end Write;
procedure Write
(This : access Score)
is
XML : XML_Writer_Access;
begin
XML := Current_Output;
Write(XML, This);
Close(XML);
end Write;
procedure Write_File
(This : access Score;
Filename : in String)
is
XML : XML_Writer_Access;
begin
XML := Create(Filename);
Write(XML, This);
Close(XML);
end Write_File;
end MusicXML;
|