Version 1 (modified by vadim.godunko, 8 years ago) ( diff )


Markup Templates Engine

Markup Templates Engine reads XML template documents and generates XML or HTML5/XHTML5 documents.

Generating of HTML5 Documents

HTML5 Writer can be used to produce optimized HTML5 documents by using most compact syntax form for attribute values and omitting optional tags.

Below is an example of its use with XML Simple Reader (it can obtain stream of SAX events from other sources too, for instance from templates processor):

with Ada.Text_IO;

with League.Strings;
with XML.SAX.Input_Sources.Streams.Files;
with XML.SAX.Output_Destinations.Strings;
with XML.SAX.Simple_Readers;
with XML.SAX.HTML5_Writers;

procedure Main is
   Input  : aliased XML.SAX.Input_Sources.Streams.Files.File_Input_Source;
   Reader : aliased XML.SAX.Simple_Readers.SAX_Simple_Reader;
   Writer : aliased XML.SAX.HTML5_Writers.HTML5_Writer;
   Output : aliased XML.SAX.Output_Destinations.Strings.SAX_String_Output_Destination;

    (League.Strings.To_Universal_String ("page.tmpl"));

   --  Configure reader.

   Reader.Set_Input_Source (Input'Unchecked_Access);
   Reader.Set_Content_Handler (Writer'Unchecked_Access);
   Reader.Set_Lexical_Handler (Writer'Unchecked_Access);

   --  Configure XML writer.

   Writer.Set_Output (Output'Unchecked_Access);

   --  Process template.


   --  Output result.

   Ada.Text_IO.Put (Output.Get_Text.To_UTF_8_String);
end Main;
Note: See TracWiki for help on using the wiki.