1-- 2-- Copyright (C) 2017, AdaCore 3-- 4 5with DOM.Core; use DOM.Core; 6with DOM.Core.Attrs; use DOM.Core.Attrs; 7with DOM.Core.Documents; use DOM.Core.Documents; 8with DOM.Core.Elements; use DOM.Core.Elements; 9with Sax.Locators; use Sax.Locators; 10 11package body DOM_With_Location is 12 13 overriding procedure Start_Element 14 (Handler : in out Tree_Reader_With_Location; 15 NS : Sax.Utils.XML_NS; 16 Local_Name : Sax.Symbols.Symbol; 17 Atts : Sax_Attribute_List) 18 is 19 Att, Att2 : Attr; 20 begin 21 -- First create the node as usual 22 Start_Element (Tree_Reader (Handler), NS, Local_Name, Atts); 23 24 -- Then add the new attribute 25 Att := Create_Attribute_NS 26 (Get_Tree (Handler), 27 Namespace_URI => "http://mydomain.com", 28 Qualified_Name => "mydomain:location"); 29 Set_Value (Att, To_String (Current_Location (Handler))); 30 31 Att2 := Set_Attribute_Node (Handler.Current_Node, Att); 32 end Start_Element; 33 34end DOM_With_Location; 35