/usr/share/ada/adainclude/xmlada_dom/dom-core.adb is in libxmlada-dom7-dev 17.1.2017-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | ------------------------------------------------------------------------------
-- XML/Ada - An XML suite for Ada95 --
-- --
-- Copyright (C) 2001-2017, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
with Unicode.CES; use Unicode.CES;
with Sax.Encodings; use Sax.Encodings;
with Unicode.Names.Basic_Latin; use Unicode.Names.Basic_Latin;
with Unicode; use Unicode;
with Sax.Symbols; use Sax.Symbols;
with Sax.Utils; use Sax.Utils;
package body DOM.Core is
use Nodes_Htable, Symbol_Table_Pointers;
Node_List_Growth_Factor : Float := Default_Node_List_Growth_Factor;
---------------------------------
-- Set_Node_List_Growth_Factor --
---------------------------------
procedure Set_Node_List_Growth_Factor (Factor : Float) is
begin
Node_List_Growth_Factor := Factor;
end Set_Node_List_Growth_Factor;
---------------------
-- Create_Document --
---------------------
function Create_Document
(Implementation : DOM_Implementation;
NameSpace_URI : DOM_String := "";
Qualified_Name : DOM_String := "";
Doc_Type : Node := null;
Symbols : Sax.Utils.Symbol_Table := Sax.Utils.No_Symbol_Table)
return Node
is
pragma Warnings (Off, NameSpace_URI);
pragma Warnings (Off, Qualified_Name);
Sym : Sax.Utils.Symbol_Table := Symbols;
Tmp : Symbol_Table_Access;
begin
pragma Assert
(Doc_Type = null or else Doc_Type.Node_Type = Document_Type_Node);
if Sym = No_Symbol_Table then
Tmp := new Symbol_Table_Record;
Sym := Symbol_Table_Pointers.Allocate (Tmp);
end if;
return new Node_Record'
(Node_Type => Document_Node,
Parent => null,
Doc_Children => Null_List,
Doc_Type => Doc_Type,
Parent_Is_Owner => False,
Implementation => Implementation,
Ids => null,
Symbols => Sym);
end Create_Document;
-----------------
-- Has_Feature --
-----------------
function Has_Feature
(Implementation : DOM_Implementation;
Feature : DOM_String;
Version : String := "2.0") return Boolean
is
pragma Warnings (Off, Implementation);
begin
return Feature = "XML" and then Version = "2.0";
end Has_Feature;
------------
-- Append --
------------
procedure Append (List : in out Node_List; N : Node) is
Old : Node_Array_Access := List.Items;
begin
if Old = null or else Old'Last = List.Last then
List.Items := new Node_Array
(0 .. List.Last + 1
+ (Integer'Max (0,
Integer (Float (List.Last) * Node_List_Growth_Factor))));
if Old /= null then
List.Items (0 .. List.Last) := Old.all;
Free (Old);
end if;
end if;
List.Last := List.Last + 1;
List.Items (List.Last) := N;
end Append;
------------
-- Remove --
------------
procedure Remove (List : in out Node_List; N : Node) is
begin
if List.Items = null or else List.Last = 0 then
Free (List.Items);
List.Last := -1;
else
for J in 0 .. List.Last loop
if List.Items (J) = N then
List.Items (J .. List.Last - 1) :=
List.Items (J + 1 .. List.Last);
List.Last := List.Last - 1;
return;
end if;
end loop;
end if;
end Remove;
----------
-- Free --
----------
procedure Free (List : in out Node_List) is
begin
Free (List.Items);
end Free;
--------------------
-- Qualified_Name --
--------------------
function Qualified_Name (N : Node_Name_Def) return DOM_String is
begin
pragma Assert (N.Local_Name /= No_Symbol);
if N.Prefix = No_Symbol or N.Prefix = Empty_String then
return Get (N.Local_Name).all;
else
return Get (N.Prefix).all & Colon_Sequence & Get (N.Local_Name).all;
end if;
end Qualified_Name;
----------------
-- Set_Prefix --
----------------
procedure Set_Prefix (N : in out Node_Name_Def; Prefix : Symbol) is
begin
-- ??? We're supposed to check that Prefix is valid, and raise
-- Invalid_Character_Err otherwise
N.Prefix := Prefix;
end Set_Prefix;
-------------------------
-- From_Qualified_Name --
-------------------------
function From_Qualified_Name
(Doc : Document;
Symbols : Sax.Utils.Symbol_Table;
Name : Sax.Symbols.Symbol;
Namespace : Sax.Symbols.Symbol := Sax.Symbols.No_Symbol)
return Node_Name_Def
is
N : constant Cst_Byte_Sequence_Access := Get (Name);
Index : Natural := N'First;
Colon_Pos : Natural;
C : Unicode_Char := 0;
begin
-- ??? Test for Invalid_Character_Err
-- ??? Must convert Tag_Name to uppercase for HTML documents
-- ??? Test for Namespace_Err
while Index <= N'Last loop
Colon_Pos := Index;
Encoding.Read (N.all, Index, C);
exit when C = Colon;
end loop;
if C = Colon then
return
(Prefix => Find (Doc.Symbols, N (N'First .. Colon_Pos - 1)),
Local_Name => Find (Doc.Symbols, N (Index .. N'Last)),
Namespace => Namespace);
elsif Symbols /= Doc.Symbols then
return
(Prefix => Find (Doc.Symbols, Get (Name).all),
Local_Name => Find (Doc.Symbols, Get (Namespace).all),
Namespace => Namespace);
else
return
(Prefix => No_Symbol,
Local_Name => Name,
Namespace => Namespace);
end if;
end From_Qualified_Name;
----------
-- Free --
----------
procedure Free (N : in out Node_String) is
pragma Unreferenced (N);
begin
null;
end Free;
-------------
-- Get_Key --
-------------
function Get_Key (N : Node_String) return Symbol is
begin
return N.Key;
end Get_Key;
---------------------
-- Document_Add_Id --
---------------------
procedure Document_Add_Id
(Doc : Document;
Id : Symbol;
Elem : Element) is
begin
if Doc.Ids = null then
Doc.Ids := new Nodes_Htable.HTable (203);
end if;
Set (Doc.Ids.all, (N => Node (Elem), Key => Id));
end Document_Add_Id;
------------------------
-- Document_Remove_Id --
------------------------
procedure Document_Remove_Id
(Doc : Document;
Id : Symbol) is
begin
if Doc.Ids /= null then
Remove (Doc.Ids.all, Id);
end if;
end Document_Remove_Id;
end DOM.Core;
|