1------------------------------------------------------------------------------ 2-- XML/Ada - An XML suite for Ada95 -- 3-- -- 4-- Copyright (C) 2001-2017, AdaCore -- 5-- -- 6-- This library is free software; you can redistribute it and/or modify it -- 7-- under terms of the GNU General Public License as published by the Free -- 8-- Software Foundation; either version 3, or (at your option) any later -- 9-- version. This library is distributed in the hope that it will be useful, -- 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- 11-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- 12-- -- 13-- As a special exception under Section 7 of GPL version 3, you are granted -- 14-- additional permissions described in the GCC Runtime Library Exception, -- 15-- version 3.1, as published by the Free Software Foundation. -- 16-- -- 17-- You should have received a copy of the GNU General Public License and -- 18-- a copy of the GCC Runtime Library Exception along with this program; -- 19-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 20-- <http://www.gnu.org/licenses/>. -- 21-- -- 22------------------------------------------------------------------------------ 23 24pragma Ada_2005; 25 26with Ada.Unchecked_Deallocation; 27with Input_Sources; 28with Interfaces; 29with Sax.Locators; 30with Sax.Exceptions; 31with Sax.Attributes; 32with Sax.Models; 33with Sax.Symbols; 34with Sax.Utils; use Sax.Utils; 35with Unicode; 36with Unicode.CES; 37with Sax.HTable; 38pragma Elaborate_All (Sax.HTable); 39 40package Sax.Readers is 41 42 type Sax_Reader is tagged private; 43 type Sax_Reader_Access is access all Sax_Reader'Class; 44 -- This package defines two types of XML readers: Reader is the historic 45 -- type; Sax_Reader was added later on. 46 -- These two readers differ by the type of parameters to their callbacks. 47 -- The callbacks of Sax_Reader require less string copying and memory 48 -- allocations, so are therefore more efficient. On the other hand, they 49 -- do not pass strings directly (for the name of the elements for instance) 50 -- but symbols (basically, naturals that can be converted to a string 51 -- through calls to Get_Symbol below). 52 -- New code is encouraged to extend Sax_Reader rather than Reader. 53 54 procedure Parse 55 (Parser : in out Sax_Reader; 56 Input : in out Input_Sources.Input_Source'Class); 57 -- Parse an XML stream, and calls the appropriate SAX callbacks for each 58 -- event. 59 -- To parse a stream, you must therefore extend the Reader or Sax_Reader 60 -- class, and override any of the callbacks (see "Content Handlers" below). 61 -- You then call Parse. 62 -- This is not re-entrant: you can not call Parse with the same Parser 63 -- argument in one of the SAX callbacks. This has undefined behavior. 64 65 procedure Set_Symbol_Table 66 (Parser : in out Sax_Reader; 67 Symbols : Symbol_Table); 68 -- Symbols is the symbol table to use. Most of the time, it should be left 69 -- to null, but you might want to share it with other parsers for 70 -- efficiency (in which case you will need to provide a task-safe version 71 -- of the symbol table). 72 -- If Symbols is null (or this subprogram is not called) a symbol table 73 -- will be created just for that parser and discarded along with the parser 74 -- 75 -- This subprogram must be called before calling Parse. 76 77 procedure Set_XML_Version 78 (Parser : in out Sax_Reader; XML : XML_Versions := XML_1_0_Fifth_Edition); 79 function Get_XML_Version (Parser : Sax_Reader) return XML_Versions; 80 -- Set the XML version to accept. 81 82 procedure Set_Feature 83 (Parser : in out Sax_Reader; Name : String; Value : Boolean); 84 function Get_Feature (Parser : Sax_Reader; Name : String) return Boolean; 85 -- Set or lookup the value of a feature 86 -- Name is a fully qualified URI, see below in "Recognized features" for 87 -- more information. 88 89 procedure Use_Basename_In_Error_Messages 90 (Parser : in out Sax_Reader; 91 Use_Basename : Boolean := True); 92 function Use_Basename_In_Error_Messages 93 (Parser : Sax_Reader) return Boolean; 94 -- Indicates whether error messages will include only the base name of 95 -- files, or the full file names. In the latter case, the error message 96 -- itself might be incomplete, since the message attached to an Ada 97 -- exception is limited to 200 characters. 98 -- For backward compatibility, the default is to show full file names. 99 100 ------------------------- 101 -- Recognized features -- 102 ------------------------- 103 -- The two strings below reference the two default features that are 104 -- recognized by all parsers. 105 106 Namespace_Feature : constant String := 107 "http://www.xml.org/sax/features/namespace"; 108 -- Controls general namespace processing. If it is true (the default), 109 -- namespace URIs will be used in events. 110 -- If False, colons (':') are allowed in tag names, and not considered 111 -- as namespace identifiers. 112 -- In fact, this is only given for full compatibility with the SAX 113 -- standard. As authorized in the standard, this parser will always 114 -- report URIs to the Start_Element and End_Element callbacks. 115 -- 116 -- Default is True. 117 118 Namespace_Prefixes_Feature : constant String := 119 "http://www.xml.org/sax/features/namespace-prefixes"; 120 -- Controls the reporting of qNames and namespace attributes (xmlns*) to 121 -- the application. 122 -- When this is False (the default), qNames may optionaly be reported, 123 -- and namespace attributes must not be reported. 124 125 -- Summary of the above two features: 126 -- 1: Namespace names 127 -- 2: Start/endPrefixMapping 128 -- 3: qNames 129 -- 4: xmlns* attributes 130 -- namespaces namespace-prefixes 1 2 3 4 131 -- true false YES YES unknown NO 132 -- true true YES YES YES YES 133 -- false false (ILLEGAL COMBINATION) 134 -- false true unknown unknown YES YES 135 -- 136 -- Default is False. 137 138 Validation_Feature : constant String := 139 "http://www.xml.org/sax/features/validation"; 140 -- If True (not the default), a number of additional tests are performed 141 -- while parsing the document, most notably that the document matches 142 -- the DTD (internal and external subset). 143 -- In such a case, the DTD must be present. 144 -- 145 -- XML/Ada doesn't currently support validating against a DTD. 146 147 Schema_Validation_Feature : constant String := 148 "http://www.adacore.com/sax/features/schema_validation"; 149 -- By default, a Sax.Readers.Reader does not try to do any validation (See 150 -- Validation_Feature above). 151 -- However, when you extend a Schema_Readers.Validating_Reader, this 152 -- feature is automatically turned on so that indeed the validating parser 153 -- by default attempts to validate XML documents. 154 155 External_General_Entities_Feature : constant String := 156 "http://xml.org/sax/features/external-general-entities"; 157 -- If True, include all external general text entities. 158 -- If False, these are not included, and will be reported with 159 -- Content_Handlers.Skipped_Entity. 160 -- 161 -- Default is True 162 163 External_Parameter_Entities_Feature : constant String := 164 "http://xml.org/sax/features/external-parameter-entities"; 165 -- If True, include all external parameter entities, including the 166 -- external DTD subset. Parameter entities are the ones defined in DTDs 167 -- and whose name starts with '%' 168 169 Parameter_Entities_Feature : constant String := 170 "http://xml.org/sax/features/lexical-handler/parameter-entities"; 171 -- True if the SAX parser will reports parameter entities through its 172 -- Lexical_Handler. 173 174 Test_Valid_Chars_Feature : constant String := 175 "http://www.adacore.com/sax/features/test_valid_chars"; 176 -- True if the SAX parser will check for each character read from the 177 -- input streams whether it is valid. This might slow done the parser, 178 -- but will provide better validation. 179 -- This is False by default. 180 181 Allow_Relative_IRI_Feature : constant String := 182 "http://www.adacore.com/sax/features/allow_relative_iri"; 183 -- By default, XML/Ada conforms to the W3C standard and forbids relative 184 -- URI in the location of namespaces. However, these were allowed by 185 -- W3C in the past, and some documents might still be using them. 186 -- If this feature is set to True, then XML/Ada will emit a warning upon 187 -- seeing a relative URI, otherwise it emits an error. 188 189 ------------------- 190 -- Error handler -- 191 ------------------- 192 -- The following functions are defined in the Error_Handler interface 193 -- in the SAX standard. 194 195 procedure Warning 196 (Handler : in out Sax_Reader; 197 Except : Sax.Exceptions.Sax_Parse_Exception'Class) is null; 198 -- Receive notification of a warning. 199 -- This method is used to report conditions that are not errors or fatal 200 -- errors. 201 -- The SAX parser must continue to provide normal parsing events after 202 -- invoking this method. 203 -- Default action is to do nothing. 204 205 procedure Error 206 (Handler : in out Sax_Reader; 207 Except : Sax.Exceptions.Sax_Parse_Exception'Class) is null; 208 -- Receive notification of a recoverable error. 209 -- For example, a validating parser would use this callback to report the 210 -- violation of a validity constraint. The default behaviour is to take no 211 -- Action. 212 -- The SAX parser must continue to provide normal parsing events after 213 -- invoking this method. If the application cannot do so, then the parser 214 -- should report a fatal error. 215 -- Default action is to do nothing. 216 217 procedure Fatal_Error 218 (Handler : in out Sax_Reader; 219 Except : Sax.Exceptions.Sax_Parse_Exception'Class); 220 -- Receive notification of a non-recoverable error. 221 -- For example, a parser would use this callback to report the violation 222 -- of a well-Formedness constraint. 223 -- The application must assume that the document is unusable after the 224 -- parser has invoked this method. Thus, a Program_Error will be raised 225 -- if your callback returns. You should always raise an exception. 226 -- Default action is to raise an exception Fatal_Error; 227 228 ---------------- 229 -- Attributes -- 230 ---------------- 231 -- Although there is a more complete attributes API in the package 232 -- Sax.Attributes, the following types are used for those more efficient 233 -- callbacks. The following attributes do not require any memory allocation 234 -- however they are only valid while the parser has not been destroyed. 235 236 type Sax_Attribute is private; 237 type Sax_Attribute_List is private; 238 -- A lighter weight version of attributes than Attributes, 239 -- based on symbols. 240 241 function Get_Index 242 (List : Sax_Attribute_List; 243 URI : Sax.Symbols.Symbol; 244 Local_Name : Sax.Symbols.Symbol) return Integer; 245 function Get_Index 246 (Handler : Sax_Reader'Class; 247 List : Sax_Attribute_List; 248 URI : Unicode.CES.Byte_Sequence; 249 Local_Name : Unicode.CES.Byte_Sequence) return Integer; 250 -- Return the index of the attribute within the list, or -1 if not found. 251 -- The first version is more efficient. The idea is that the symbols can be 252 -- computed once when the parsing starts, and then reused. They are much 253 -- faster to compare than strings. 254 -- The second version is provided to help transitions. 255 -- 256 -- A more efficient approach is to traverse the list of attributes only 257 -- once and store the values in your own record, rather than traverse the 258 -- list of attributes every time you need to access a value: 259 -- 260 -- Name : Qualified_Name; 261 -- for J in 1 .. Get_Length (List) loop 262 -- Name := Get_Qualified_Name (List, J); 263 -- if Name.NS = Empty_String and then Name.Local = ... then 264 -- ...; 265 -- elsif ... then 266 -- ... 267 -- end if; 268 -- end loop; 269 270 procedure Set_Value 271 (List : Sax_Attribute_List; 272 Index : Integer; 273 Val : Sax.Symbols.Symbol); 274 function Get_Value 275 (List : Sax_Attribute_List; Index : Integer) return Sax.Symbols.Symbol; 276 -- Returns No_Symbol if Index is negative. 277 -- Use Get (Get_Value (List, Index)).all to retrive the strings value 278 -- (or in Ada05 dotted notation: Get_Value (List, Index).Get.all 279 280 function Get_Location 281 (List : Sax_Attribute_List; Index : Integer) return Sax.Locators.Location; 282 -- Return the start location for this attribute 283 284 function Get_Non_Normalized_Value 285 (List : Sax_Attribute_List; Index : Integer) return Sax.Symbols.Symbol; 286 function Get_Value_As_Boolean 287 (List : Sax_Attribute_List; Index : Integer; Default : Boolean := False) 288 return Boolean; 289 pragma Inline (Get_Value, Get_Non_Normalized_Value, Get_Value_As_Boolean); 290 -- Return the value of the corresponding attribute. 291 -- [Default] is returned if the attribute does not exist 292 293 procedure Set_Normalized_Value 294 (List : Sax_Attribute_List; Index : Integer; Value : Sax.Symbols.Symbol); 295 pragma Inline (Set_Normalized_Value); 296 -- Set the normalized value of the attribute 297 298 function Get_Type 299 (List : Sax_Attribute_List; Index : Integer) 300 return Sax.Attributes.Attribute_Type; 301 procedure Set_Type 302 (List : Sax_Attribute_List; Index : Integer; 303 Typ : Sax.Attributes.Attribute_Type); 304 pragma Inline (Get_Type, Set_Type); 305 -- Return the type of the attribute 306 307 function Get_Length (List : Sax_Attribute_List) return Natural; 308 pragma Inline (Get_Length); 309 -- Return the number of attributes in the list 310 311 procedure Append 312 (List : in out Sax_Attribute_List; 313 Local_Name : Sax.Symbols.Symbol; 314 Prefix : Sax.Symbols.Symbol; 315 Att_Type : Sax.Attributes.Attribute_Type := Sax.Attributes.Cdata; 316 URI : Sax.Symbols.Symbol := Sax.Symbols.No_Symbol; 317 Value : Sax.Symbols.Symbol; 318 Location : Sax.Locators.Location; 319 Default_Decl : Sax.Attributes.Default_Declaration := 320 Sax.Attributes.Default; 321 If_Unique : Boolean := False); 322 -- Append a new attribute to the list. 323 -- If If_Unique is true, the attribute is not added if it is already in 324 -- the list. 325 326 type Qualified_Name is record 327 NS : Sax.Symbols.Symbol; 328 Local : Sax.Symbols.Symbol; 329 end record; 330 No_Qualified_Name : constant Qualified_Name := 331 (Sax.Symbols.No_Symbol, Sax.Symbols.No_Symbol); 332 333 function Get_Prefix 334 (List : Sax_Attribute_List; Index : Integer) return Sax.Symbols.Symbol; 335 function Get_Name 336 (List : Sax_Attribute_List; Index : Integer) return Qualified_Name; 337 function Get_Qname 338 (List : Sax_Attribute_List; Index : Integer) 339 return Unicode.CES.Byte_Sequence; -- Using the prefix 340 pragma Inline (Get_Prefix, Get_Name, Get_QName); 341 -- Return the various name components of the attribute 342 343 ---------------------- 344 -- Content Handlers -- 345 ---------------------- 346 -- The following functions are defined in the Content_Handler interface 347 -- in the SAX standard. 348 -- The default for all the subprograms below is to do nothing, unless 349 -- otherwise specified. 350 351 procedure Set_Document_Locator 352 (Handler : in out Sax_Reader; Loc : in out Sax.Locators.Locator) is null; 353 -- Receive an object for locating the origin of SAX document events. 354 -- SAX parsers are strongly encouraged but not required to give this 355 -- information. This callback will always be called before any other. 356 -- Note that [Loc] is only valid within the call to [Parse], and will be 357 -- free on exit, so should no longer be referenced. 358 -- In practice, this callback (mandated by the standard), is not so very 359 -- useful and direct calls to [Locator] below should be preferred. 360 361 function Current_Location 362 (Handler : Sax_Reader) return Sax.Locators.Location; 363 pragma Inline (Current_Location); 364 -- Return the current location in the stream (or [No_Location] if parsing 365 -- has finished or not started). 366 367 procedure Start_Document (Handler : in out Sax_Reader) is null; 368 -- Receive notification of the beginning of a document. 369 -- This callback is called only once by the parser, before any other 370 -- function in this interface except Set_Document_Locator. 371 372 procedure End_Document (Handler : in out Sax_Reader) is null; 373 -- Receive notification of the end of a document. 374 -- This callback will be called only once once it has reached the end of 375 -- the input stream. It won't be called if a Fatal_Error is raised, it is 376 -- your responsability to call the callback yourself in this case. 377 378 procedure Start_Prefix_Mapping 379 (Handler : in out Sax_Reader; 380 Prefix : Sax.Symbols.Symbol; 381 URI : Sax.Symbols.Symbol) is null; 382 -- Begin the scope of a prefix-URI mapping. 383 -- This callback is not necessarily for normal namespace processing, since 384 -- the SAX parser will automatically substitute prefixes for elements and 385 -- attributes if XML_Readers.Namespace_Feature is set to True. 386 -- However, there are cases where the automatic replacement can not be 387 -- safely done, and in this case this callback is invoked. 388 -- It is not garanteed that calls to End_Prefix_Mapping will occur in the 389 -- same order (or the reverse one) as Start_Prefix_Mapping. 390 391 procedure End_Prefix_Mapping 392 (Handler : in out Sax_Reader; 393 Prefix : Sax.Symbols.Symbol) is null; 394 -- End the scope of a prefix-URI mapping. 395 -- This will always occur after the corresponding End_Element event. 396 397 procedure Start_Element 398 (Handler : in out Sax_Reader; 399 NS : Sax.Utils.XML_NS; 400 Local_Name : Sax.Symbols.Symbol; 401 Atts : Sax_Attribute_List) is null; 402 -- Receive notification of the beginning of an element. 403 -- There will always be a matching call to End_Element, even for empty 404 -- elements. 405 -- Up to three name components can be given for each element, depending 406 -- on the value of the XML_Reader features. 407 -- - Namespace_URI and Local_Name are required when Namespace_Feature is 408 -- True, but are optional if False. If one is specified, both must be. 409 -- - Qname (qualified name) is required if Namespace_Prefixes_Feature is 410 -- True, and optional if False. This is basically of the form "Ns:Name" 411 -- The attribute list will only contain attributes with explicit values. It 412 -- will contain attributes used for namespace declaration (xmlns*) only if 413 -- Namespace_Prefixes_Feature is True. 414 -- 415 -- For users of older versions of XML/Ada, the old profile of Start_Element 416 -- is still available if you derive from the "Reader" type (below) instead 417 -- of "Sax_Reader". We do encourage you to transition to the new profiles 418 -- at your convenience, though, because they provide greater efficiency, 419 -- mostly by limiting the number of string comparison and allocations. 420 421 procedure End_Element 422 (Handler : in out Sax_Reader; 423 NS : Sax.Utils.XML_NS; 424 Local_Name : Sax.Symbols.Symbol) is null; 425 -- Receive notification of the end of an element. 426 427 procedure Characters 428 (Handler : in out Sax_Reader; 429 Ch : Unicode.CES.Byte_Sequence) is null; 430 -- Receives notification of character data. 431 -- XML parsers may return all contiguous character data in a single chunk, 432 -- or they may split them into several chunks. However, all of the 433 -- characters in any single event must come from the same external entity 434 -- so that the Locator provides useful information 435 -- 436 -- Note that some parsers will report (and validating parsers must) report 437 -- whitespace between elements using the Ignorable_Whitespace event. 438 439 procedure Ignorable_Whitespace 440 (Handler : in out Sax_Reader; 441 Ch : Unicode.CES.Byte_Sequence) is null; 442 -- Receive notification of ignorable whitespace in element content (ie 443 -- for elements whose xml:space attribute is not set to 'preserve', see 444 -- XML specifications 2.10) 445 -- If there is only white spaces between two tags, they are reported via 446 -- this callback. 447 -- SAX parsers may return all contiguous whitespace in a single chunk, or 448 -- they may split it into several chunks. 449 450 procedure Processing_Instruction 451 (Handler : in out Sax_Reader; 452 Target : Unicode.CES.Byte_Sequence; 453 Data : Unicode.CES.Byte_Sequence) is null; 454 -- Receive notification of a processing instruction. 455 -- A SAX parser must never report an XML declaration (<?xml..?>, 2.8 in 456 -- XML specifications) or a text declaration (<?xml?>, 4.3.1 in XML 457 -- specifications) using this method. 458 459 procedure Skipped_Entity 460 (Handler : in out Sax_Reader; 461 Name : Sax.Symbols.Symbol) is null; 462 -- Receive notification of a skipped entity. 463 -- The Parser will invoke this method once for each entity 464 -- skipped. Non-validating processors may skip entities if they have not 465 -- seen the declarations (because, for example, the entity was declared in 466 -- an external DTD subset). All processors may skip external Entities, 467 -- depending on the value of External_General_Entities_Feature and 468 -- External_Parameter_Entities_Feature. 469 -- 470 -- Name is the name of the skipped entity. If it is a parameter entity, 471 -- the name will begin with '%', and if it is the external DTD subset, 472 -- it will be the string "[dtd]". 473 474 ------------------ 475 -- DTD Handlers -- 476 ------------------ 477 -- The following functions are defined in the DTD_Handler interface 478 -- in the SAX standard. 479 480 procedure Unparsed_Entity_Decl 481 (Handler : in out Sax_Reader; 482 Name : Unicode.CES.Byte_Sequence; 483 System_Id : Unicode.CES.Byte_Sequence; 484 Notation_Name : Unicode.CES.Byte_Sequence) is null; 485 -- Receive notification of an unparsed entity declaration event. 486 -- This is for entities like "<!ENTITY foo SYSTEM ".." NDATA gif>" 487 488 procedure Notation_Decl 489 (Handler : in out Sax_Reader; 490 Name : Unicode.CES.Byte_Sequence; 491 Public_Id : Unicode.CES.Byte_Sequence; 492 System_Id : Unicode.CES.Byte_Sequence) is null; 493 -- Receive notification of a notation declaration event. 494 -- At least one of publicId and systemId must be non-null. If a system 495 -- identifier is present, and it is a URL, the SAX parser must resolve it 496 -- fully before passing it to the application through this event. 497 -- There is no guarantee that the notation declaration will be reported 498 -- before any unparsed entities that use it. 499 500 --------------------- 501 -- Entity Resolver -- 502 --------------------- 503 -- The following functions are defined in the Entity_Resolver interface 504 -- in the SAX standard. 505 506 function Resolve_Entity 507 (Handler : Sax_Reader; 508 Public_Id : Unicode.CES.Byte_Sequence; 509 System_Id : Unicode.CES.Byte_Sequence) 510 return Input_Sources.Input_Source_Access; 511 -- Allow the application to resolve external entities. 512 -- The parser will call this method before opening any external entity 513 -- except the top-level document entity. Such entities include the external 514 -- DTD subset and external parameter entities referenced within the DTD (in 515 -- either case, only if the parser reads external parameter entities), and 516 -- external general entities referenced within the document element (if the 517 -- parser reads external general entities). The application may request 518 -- that the parser locate the entity itself, that it use an alternative 519 -- URI, or that it use data provided by the application (as a character or 520 -- byte input stream). 521 -- Application writers can use this method to redirect external system 522 -- identifiers to secure and/or local URIs, to look up public identifiers 523 -- in a catalogue, or to read an entity from a database or other input 524 -- source (including, for example, a dialog box). Neither XML nor SAX 525 -- specifies a preferred policy for using public or system IDs to resolve 526 -- resources. However, SAX specifies how to interpret any InputSource 527 -- returned by this method, and that if none is returned, then the system 528 -- ID will be dereferenced as a URL. 529 -- 530 -- If the returned value is null, the standard algorithm is used. Otherwise 531 -- the returend value is automatically freed by the parser when no longer 532 -- needed. 533 -- 534 -- Calls to this subprogram are nested within Start_Entity/End_Entity. 535 536 --------------------- 537 -- Lexical Handler -- 538 --------------------- 539 -- The following functions are defined in the Lexical_Handler interface 540 -- in the extended SAX standard. This is not part of the standard itself, 541 -- but rather part of the extension for it. 542 -- Note that the SAX standard indicates that such extended handlers should 543 -- be set through properties, but this is not necessary in this 544 -- implementation where you simply have to override the following 545 -- subprograms. 546 547 procedure Comment 548 (Handler : in out Sax_Reader; Ch : Unicode.CES.Byte_Sequence) is null; 549 -- Report an XML comment anywhere in the document. 550 -- Default behavior is to do nothing. 551 552 procedure Start_Cdata (Handler : in out Sax_Reader) is null; 553 -- Report the start of a CData section. 554 -- The content of the section is reported through the usual Characters 555 -- event, this only acts as the boundary. 556 557 procedure End_Cdata (Handler : in out Sax_Reader) is null; 558 -- Report the end of a CData section 559 560 procedure Start_Entity 561 (Handler : in out Sax_Reader; 562 Name : Sax.Symbols.Symbol) is null; 563 -- Report the beginning of some internal and external XML entities. 564 -- Check the feature Parameter_Entities_Feature to know if the handler 565 -- will report these events. 566 567 procedure End_Entity 568 (Handler : in out Sax_Reader; 569 Name : Sax.Symbols.Symbol) is null; 570 -- Report the end of an entity 571 572 procedure Start_DTD 573 (Handler : in out Sax_Reader; 574 Name : Unicode.CES.Byte_Sequence; 575 Public_Id : Unicode.CES.Byte_Sequence := ""; 576 System_Id : Unicode.CES.Byte_Sequence := "") is null; 577 -- Report the start of DTD declarations, if any. 578 -- All events reported to a Decl_Handler are reported between a Start_DTD 579 -- and an End_DTD event. 580 -- Public_Id and System_Id might be the empty string if none was declared. 581 -- The events following Start_DTD (and before the matching End_DTD) are 582 -- assumed to be part of the internal subset of the DTD, unless they 583 -- appear between a Start_Entity and End_Entity events (with "[dtd]" for 584 -- the name). 585 586 procedure End_DTD (Handler : in out Sax_Reader) is null; 587 -- Report the end of a DTD section 588 589 ------------------ 590 -- Decl Handler -- 591 ------------------ 592 -- The following functions are defined in the Decl_Handler interface 593 -- in the extended SAX standard. This is not part of the standard itself, 594 -- but rather part of the extension for it. 595 596 procedure Internal_Entity_Decl 597 (Handler : in out Sax_Reader; 598 Name : Unicode.CES.Byte_Sequence; 599 Value : Unicode.CES.Byte_Sequence) is null; 600 -- Report an internal entity declaration. 601 -- This is for <!ENTITY...> notations in the DTD, where the value is 602 -- specified directly as a string. 603 -- Only the effective (first) declaration for each entity will be reported. 604 -- All parameter entities in the value will be expanded, but general 605 -- entities will not. 606 -- For Parameter entities, Name will start with '%' 607 608 procedure External_Entity_Decl 609 (Handler : in out Sax_Reader; 610 Name : Unicode.CES.Byte_Sequence; 611 Public_Id : Unicode.CES.Byte_Sequence; 612 System_Id : Unicode.CES.Byte_Sequence) is null; 613 -- Report a parsed external entity declaration, ie when their value is 614 -- not defined as a string. 615 616 procedure Element_Decl 617 (Handler : in out Sax_Reader; 618 Name : Unicode.CES.Byte_Sequence; 619 Model : Sax.Models.Content_Model) is null; 620 -- Report an element type declaration. 621 -- Model represents the content model for this element. If you need to keep 622 -- a copy of it, you must Ref it, and Unref it when you no longer need the 623 -- copy, for proper memory management. 624 -- The model is normalized so that all parameter entities are fully 625 -- resolved and all whitespace is removed,and includes the enclosing 626 -- parentheses. 627 628 procedure Attribute_Decl 629 (Handler : in out Sax_Reader; 630 Ename : Unicode.CES.Byte_Sequence; 631 Aname : Unicode.CES.Byte_Sequence; 632 Typ : Sax.Attributes.Attribute_Type; 633 Content : Sax.Models.Content_Model; 634 Value_Default : Sax.Attributes.Default_Declaration; 635 Value : Unicode.CES.Byte_Sequence) is null; 636 -- Report an attribute type declaration. 637 -- Only the first declaration for an attribute will be reported. 638 -- If Typ is Notation or Enumeration, then Content will contain the 639 -- description model for the attribute. Otherwise Content is null. 640 -- If you need to keep a copy of Content, you must Ref it, and Unref it 641 -- when you are done using it. 642 -- Value_Default represents the attribute default requirements 643 -- ("#IMPLIED", "#REQUIRED", or "#FIXED"). 644 -- Value is a string representing the attribute's default value, or "" 645 -- if there is none 646 647 XML_Fatal_Error : exception; 648 649 ------------------- 650 -- Misc services -- 651 ------------------- 652 653 function Prefix_From_Qname (Qname : Unicode.CES.Byte_Sequence) 654 return Unicode.CES.Byte_Sequence; 655 -- Return the prefix part of Qname, or the empty string if no explicit 656 -- prefix is defined. 657 658 ----------- 659 -- Hooks -- 660 ----------- 661 -- A parser will call some hooks before it calls the primitive operations 662 -- like Start_Element,... 663 -- These hooks are meant for internal use only at this point, since it is 664 -- cleaner for the user to simply extend the primitive operation. 665 -- These are currently used to plug in an XML validator while limiting the 666 -- dependencies between the SAX and Schema modules. 667 668 type Hook_Data is abstract tagged null record; 669 type Hook_Data_Access is access all Hook_Data'Class; 670 671 procedure Free (Data : in out Hook_Data) is abstract; 672 -- Free the memory associated with the data 673 674 type Element is private; 675 type Element_Access is access Element; 676 677 function To_QName 678 (Namespace_URI, Local_Name : Sax.Symbols.Symbol) 679 return Unicode.CES.Byte_Sequence; 680 function To_QName 681 (Elem : Element_Access) return Unicode.CES.Byte_Sequence; 682 -- Return the qualified name "{namespace_uri}local_name" 683 684 function Start_Tag_Location 685 (Elem : Element_Access) return Sax.Locators.Location; 686 function Start_Tag_End_Location 687 (Elem : Element_Access) return Sax.Locators.Location; 688 -- The location for the start of the element (start tag and end tag). 689 690 function Get_NS (Elem : Element_Access) return XML_NS; 691 function Get_Local_Name (Elem : Element_Access) return Sax.Symbols.Symbol; 692 pragma Inline (Get_NS, Get_Local_Name); 693 -- Return the name and local name of the element 694 695 procedure Initialize_Symbols (Parser : in out Sax_Reader); 696 -- Initialize the symbol table with some predefined symbols 697 698 function Find_Symbol 699 (Parser : Sax_Reader'Class; 700 Str : Unicode.CES.Byte_Sequence) return Sax.Symbols.Symbol; 701 function Get_Symbol_Table (Parser : Sax_Reader'Class) return Symbol_Table; 702 -- Manipulation of symbols 703 704 procedure Find_NS 705 (Parser : Sax_Reader'Class; 706 Prefix : Sax.Symbols.Symbol; 707 NS : out XML_NS; 708 Include_Default_NS : Boolean := True); 709 -- Search the namespace associated with a given prefix in the scope of 710 -- Elem or its parents. Use the empty string to get the default namespace. 711 -- Fatal_Error is raised if no such namespace was found (and null is 712 -- returned, in case Fatal_Error didn't raise an exception) 713 -- The default namespace is not resolved if Include_Default_NS is False. 714 -- Returns No_XML_NS if the namespace is not defined 715 716 procedure Find_NS_From_URI 717 (Parser : in out Sax_Reader'Class; 718 URI : Sax.Symbols.Symbol; 719 NS : out XML_NS); 720 -- Return the XML_NS for URI. There could be several, and the most recent 721 -- one is returned (that is with the prefix that was defined last in the 722 -- current context. 723 -- Returns No_XML_NS if the namespace is not defined 724 725 type Start_Element_Hook is access procedure 726 (Handler : access Sax_Reader'Class; 727 Element : Element_Access; 728 Atts : access Sax_Attribute_List); 729 -- This hook should take the opportunity of normalizing attribute values 730 -- if necessary (basic normalization is already done by the SAX parser, 731 -- but based on information extracted from schemas, further normalization 732 -- might be needed). 733 -- The list of attributes Atts has not been checked, and thus some of the 734 -- attributes might have wrong values, or some attributes might be missing. 735 -- This hook is really intended for validating parsers to do their own 736 -- checks in any case. Standard applications should override Start_Element. 737 738 type End_Element_Hook is access procedure 739 (Handler : access Sax_Reader'Class; Elem : Element_Access); 740 type Characters_Hook is access procedure 741 (Handler : access Sax_Reader'Class; Ch : Unicode.CES.Byte_Sequence); 742 type Whitespace_Hook is access procedure 743 (Handler : access Sax_Reader'Class; Ch : Unicode.CES.Byte_Sequence); 744 type Set_Doc_Locator_Hook is access procedure 745 (Handler : in out Sax_Reader'Class; 746 Loc : in out Sax.Locators.Locator); 747 type Notation_Decl_Hook is access procedure 748 (Handler : access Sax_Reader'Class; 749 Name : Unicode.CES.Byte_Sequence; 750 Public_Id : Unicode.CES.Byte_Sequence; 751 System_Id : Unicode.CES.Byte_Sequence); 752 753 function Get_Hooks_Data (Handler : Sax_Reader) return Hook_Data_Access; 754 -- Return the hook data that was set through Set_Hooks. This could be null 755 756 procedure Set_Hooks 757 (Handler : in out Sax_Reader; 758 Data : Hook_Data_Access := null; 759 Start_Element : Start_Element_Hook := null; 760 End_Element : End_Element_Hook := null; 761 Characters : Characters_Hook := null; 762 Whitespace : Whitespace_Hook := null; 763 Doc_Locator : Set_Doc_Locator_Hook := null; 764 Notation_Decl : Notation_Decl_Hook := null); 765 -- Set a list of hooks to be called before calling the usual primitive 766 -- operations. These override hooks that were defined previously. 767 -- Data will be passed to each of the hook. It is automatically 768 -- deallocated when no longer needed by the parser (ie the next call to 769 -- Set_Hooks or when the parser itself is freed). 770 771 procedure Error (Parser : in out Sax_Reader'Class; Msg : String); 772 -- Raises an error 773 774 ------------ 775 -- Reader -- 776 ------------ 777 778 type Reader is new Sax_Reader with private; 779 type Reader_Access is access all Reader'Class; 780 -- This is the old type that was provided by this package 781 782 procedure Start_Prefix_Mapping 783 (Handler : in out Reader; 784 Prefix : Unicode.CES.Byte_Sequence; 785 URI : Unicode.CES.Byte_Sequence) is null; 786 procedure End_Prefix_Mapping 787 (Handler : in out Reader; 788 Prefix : Unicode.CES.Byte_Sequence) is null; 789 procedure Start_Element 790 (Handler : in out Reader; 791 Namespace_URI : Unicode.CES.Byte_Sequence := ""; 792 Local_Name : Unicode.CES.Byte_Sequence := ""; 793 Qname : Unicode.CES.Byte_Sequence := ""; 794 Atts : Sax.Attributes.Attributes'Class) is null; 795 procedure End_Element 796 (Handler : in out Reader; 797 Namespace_URI : Unicode.CES.Byte_Sequence := ""; 798 Local_Name : Unicode.CES.Byte_Sequence := ""; 799 Qname : Unicode.CES.Byte_Sequence := "") is null; 800 procedure Skipped_Entity 801 (Handler : in out Reader; 802 Name : Unicode.CES.Byte_Sequence) is null; 803 procedure Start_Entity 804 (Handler : in out Reader; 805 Name : Unicode.CES.Byte_Sequence) is null; 806 procedure End_Entity 807 (Handler : in out Reader; 808 Name : Unicode.CES.Byte_Sequence) is null; 809 -- See documentation for similarly named callbacks for Sax_Reader. 810 -- These subprograms require extra processing and are less efficient than 811 -- the above subprograms 812 813 overriding procedure Start_Prefix_Mapping 814 (Handler : in out Reader; 815 Prefix : Sax.Symbols.Symbol; 816 URI : Sax.Symbols.Symbol); 817 overriding procedure End_Prefix_Mapping 818 (Handler : in out Reader; Prefix : Sax.Symbols.Symbol); 819 overriding procedure Start_Element 820 (Handler : in out Reader; 821 NS : Sax.Utils.XML_NS; 822 Local_Name : Sax.Symbols.Symbol; 823 Atts : Sax_Attribute_List); 824 overriding procedure End_Element 825 (Handler : in out Reader; 826 NS : Sax.Utils.XML_NS; 827 Local_Name : Sax.Symbols.Symbol); 828 overriding procedure Skipped_Entity 829 (Handler : in out Reader; 830 Name : Sax.Symbols.Symbol); 831 overriding procedure Start_Entity 832 (Handler : in out Reader; 833 Name : Sax.Symbols.Symbol); 834 overriding procedure End_Entity 835 (Handler : in out Reader; 836 Name : Sax.Symbols.Symbol); 837 -- See inherited documentation 838 839private 840 841 type Parser_Hooks is record 842 Data : Hook_Data_Access := null; 843 Start_Element : Start_Element_Hook := null; 844 End_Element : End_Element_Hook := null; 845 Characters : Characters_Hook := null; 846 Whitespace : Whitespace_Hook := null; 847 Doc_Locator : Set_Doc_Locator_Hook := null; 848 Notation_Decl : Notation_Decl_Hook := null; 849 end record; 850 851 Entities_Table_Size : constant := 50; 852 -- Size of the hash-table used to store entities. 853 -- This is not a hard limit on the number of entities that can be defined. 854 -- However, if this number is too small with regards to the number of 855 -- entities, there will be conflicts in the hash-table that will slow 856 -- down the lookup. 857 858 Default_Atts_Table_Size : constant := 50; 859 -- Size of the hash-table used to store the default attributes 860 861 function Hash (Str : String) return Interfaces.Unsigned_32; 862 -- Compute hash function for given String 863 864 -------------- 865 -- Entities -- 866 -------------- 867 -- We need to memorize all the declared entities, so as to do the 868 -- substitution ourselves. 869 870 type Entity_Entry is record 871 Name : Sax.Symbols.Symbol; 872 Value : Sax.Symbols.Symbol := Sax.Symbols.No_Symbol; 873 Public : Sax.Symbols.Symbol; 874 875 External : Boolean; 876 -- Whether the entity references an external document 877 878 Unparsed : Boolean; 879 -- Whether we have an unparsed entity (ie using a NOTATION) 880 881 External_Declaration : Boolean; 882 -- Whether the entity was defined in the external subset 883 884 Already_Read : Boolean := False; 885 -- True if the value of the entity was already read. This is used to 886 -- detect entities referencing themselves. 887 end record; 888 type Entity_Entry_Access is access Entity_Entry; 889 890 procedure Free is new Ada.Unchecked_Deallocation 891 (Entity_Entry, Entity_Entry_Access); 892 function Get_Key (Entity : Entity_Entry_Access) return Sax.Symbols.Symbol; 893 894 package Entity_Table is new Sax.HTable 895 (Element => Entity_Entry_Access, 896 Empty_Element => null, 897 Free => Free, 898 Key => Sax.Symbols.Symbol, 899 Get_Key => Get_Key, 900 Hash => Sax.Symbols.Hash, 901 Equal => Sax.Symbols."="); 902 903 type Entity_Input_Source; 904 type Entity_Input_Source_Access is access Entity_Input_Source; 905 type Entity_Input_Source is record 906 External : Boolean; 907 Next : Entity_Input_Source_Access; 908 Name : Sax.Symbols.Symbol; 909 -- Name of the entity 910 911 Handle_Strings : Boolean := True; 912 -- True if " and ' should be recognized as special characters. 913 -- This is used so that a string started in one stream isn't terminated 914 -- in another entity or stream. 915 916 System_Id : Sax.Symbols.Symbol; 917 Public_Id : Sax.Symbols.Symbol; 918 -- Uniq System_Id for each input source 919 920 Input : Input_Sources.Input_Source_Access; 921 Save_Loc : Sax.Locators.Location; 922 end record; 923 924 type Parser_State is record 925 Name : String (1 .. 3); 926 -- Name of the state (debugging purposes) 927 928 Ignore_Special : Boolean := False; 929 -- True if special characters should be ignored (as is the case in 930 -- strings). ??? Could be ignored, duplicates Greater_Special, 931 -- Less_Special, .. 932 933 Detect_End_Of_PI : Boolean := False; 934 -- Whether ?> should be reported as end of PI 935 936 Greater_Special : Boolean := False; 937 -- Whether > is considered a special character 938 939 Less_Special : Boolean := False; 940 -- Should be true if < should be reported separately. Note that in that 941 -- case it won't even be associated with the following character if 942 -- it is '!', '?',... 943 944 Expand_Param_Entities : Boolean := False; 945 -- True if %...; param entities should be recognized, as is the case in 946 -- the DTD 947 948 Expand_Entities : Boolean := True; 949 -- True if &...; should be recognized 950 951 Report_Character_Ref : Boolean := False; 952 -- True if character references &#...; should be reported as a single 953 -- token, with their replacement character stored in the buffer. 954 -- Ignored if Expand_Character_Ref is True. 955 956 Expand_Character_Ref : Boolean := True; 957 -- True if character references &#...; should be recognized and 958 -- expanded 959 960 In_DTD : Boolean := False; 961 -- True if we are parsing the DTD, and '['. ']' and '<!' should be 962 -- recognized as special tags 963 964 Recognize_External : Boolean := False; 965 -- True if PUBLIC, SYSTEM and NDATA should be recognized as special 966 -- tokens 967 968 In_Attlist : Boolean := False; 969 -- True if we are in an <!ATTLIST, and we should recognize special 970 -- keywords like ID, NMTOKEN,... 971 972 Handle_Strings : Boolean := False; 973 -- True if " and ' should be recognized as special characters 974 -- ??? Should be merged with a In_String field, that would also replace 975 -- Ignore_Special. 976 977 In_Tag : Boolean := False; 978 -- True if = and : should be recognized as special characters 979 980 Report_Parenthesis : Boolean := False; 981 -- True if Opening_Parenthesis should be reported separately 982 end record; 983 984 type Element is record 985 NS : XML_NS; 986 Name : Sax.Symbols.Symbol; 987 Parent : Element_Access; 988 Start : Sax.Locators.Location; -- Start tag location 989 Start_Tag_End : Sax.Locators.Location := Sax.Locators.No_Location; 990 -- Character after start tag (ie first char of content) 991 Namespaces : XML_NS; 992 -- Namespaces defined for that element and its children 993 end record; 994 995 type Sax_Attribute is record 996 Prefix : Sax.Symbols.Symbol; 997 Local_Name : Sax.Symbols.Symbol; 998 Value : Sax.Symbols.Symbol; 999 Non_Normalized_Value : Sax.Symbols.Symbol; 1000 URI : Sax.Symbols.Symbol; 1001 Att_Type : Sax.Attributes.Attribute_Type := Sax.Attributes.Cdata; 1002 Default_Decl : Sax.Attributes.Default_Declaration := 1003 Sax.Attributes.Default; 1004 Location : Sax.Locators.Location; -- Where the declaration occurred 1005 end record; 1006 -- An attribute as read in the XML stream. This is used to temporarily 1007 -- store the list of attributes until we have parsed all the namespace 1008 -- declarations, after which a regular list of attributes is created. 1009 1010 type Sax_Attribute_Array is array (Natural range <>) of Sax_Attribute; 1011 type Sax_Attribute_Array_Access is access all Sax_Attribute_Array; 1012 -- A list of attributes. 1013 1014 type Sax_Attribute_List is record 1015 Count : Natural := 0; 1016 List : Sax_Attribute_Array_Access; 1017 end record; 1018 1019 type Attributes_Entry is record 1020 Element_Name : Sax.Symbols.Symbol; 1021 Attributes : Sax_Attribute_List; 1022 end record; 1023 Null_Attribute : constant Attributes_Entry := 1024 (Sax.Symbols.No_Symbol, (0, null)); 1025 1026 procedure Free (Att : in out Attributes_Entry); 1027 function Get_Key (Att : Attributes_Entry) return Sax.Symbols.Symbol; 1028 1029 package Attributes_Table is new Sax.HTable 1030 (Element => Attributes_Entry, 1031 Empty_Element => Null_Attribute, 1032 Free => Free, 1033 Key => Sax.Symbols.Symbol, 1034 Get_Key => Get_Key, 1035 Hash => Sax.Symbols.Hash, 1036 Equal => Sax.Symbols."="); 1037 1038 type Notation_Entry is record 1039 Name : Sax.Symbols.Symbol; 1040 Declaration_Seen : Boolean; 1041 end record; 1042 Null_Notation : constant Notation_Entry := (Sax.Symbols.No_Symbol, False); 1043 1044 procedure Free (Notation : in out Notation_Entry); 1045 function Get_Key (Notation : Notation_Entry) return Sax.Symbols.Symbol; 1046 1047 package Notations_Table is new Sax.HTable 1048 (Element => Notation_Entry, 1049 Empty_Element => Null_Notation, 1050 Free => Free, 1051 Key => Sax.Symbols.Symbol, 1052 Get_Key => Get_Key, 1053 Hash => Sax.Symbols.Hash, 1054 Equal => Sax.Symbols."="); 1055 -- For notations, we simply store whether they have been defined or not, 1056 -- and then only for validating parsers 1057 1058 type Sax_Reader is tagged record 1059 Buffer_Length : Natural := 0; 1060 Buffer : Unicode.CES.Byte_Sequence_Access; 1061 1062 Attributes : aliased Sax_Attribute_List; 1063 -- List of attributes for the current element. This array is to limit 1064 -- the number of memory allocations, by reusing it for each element. 1065 1066 Locator : Sax.Locators.Locator; 1067 Current_Node : Element_Access; 1068 1069 Public_Id : Sax.Symbols.Symbol; 1070 System_Id : Sax.Symbols.Symbol; 1071 -- The initial file we were parsing. 1072 1073 Symbols : Symbol_Table; 1074 Lt_Sequence : Sax.Symbols.Symbol := Sax.Symbols.No_Symbol; 1075 Gt_Sequence : Sax.Symbols.Symbol; 1076 Amp_Sequence : Sax.Symbols.Symbol; 1077 Apos_Sequence : Sax.Symbols.Symbol; 1078 Quot_Sequence : Sax.Symbols.Symbol; 1079 Xmlns_Sequence : Sax.Symbols.Symbol; 1080 Namespaces_URI_Sequence : Sax.Symbols.Symbol; 1081 Xml_Sequence : Sax.Symbols.Symbol; 1082 Symbol_Percent : Sax.Symbols.Symbol; 1083 Symbol_Ampersand : Sax.Symbols.Symbol; 1084 -- The symbol table, and a few predefined symbols 1085 1086 Inputs : Entity_Input_Source_Access; 1087 -- Entities and parameter entities are processed inline (if we 1088 -- temporarily substitute the input stream with the replacement text 1089 -- for the entity). 1090 -- When Inputs is null, the characters are read from the input stream 1091 -- given in the call to Parser. 1092 1093 Close_Inputs : Entity_Input_Source_Access; 1094 -- List of entities to be closed at the next call to Next_Token 1095 1096 Default_Atts : Attributes_Table.HTable (Default_Atts_Table_Size); 1097 -- This table contains the list of default attributes defined for 1098 -- each element in the DTD. Index is the name of the elements. 1099 -- Note that the namespaces haven't been resolved for these default 1100 -- attributes, since in some cases the namespace itself could be defined 1101 -- as a default attribute. 1102 1103 Notations : Notations_Table.HTable (Default_Atts_Table_Size); 1104 -- List of notations defined in the XML document. This is left empty 1105 -- if the parser isn't configured to do validation. 1106 1107 Entities : Entity_Table.HTable (Entities_Table_Size); 1108 1109 DTD_Name : Sax.Symbols.Symbol := Sax.Symbols.No_Symbol; 1110 -- Name of the DTD, and also name of the root element (in case we have 1111 -- a validating parser). This is left to null for non-validating 1112 -- parsers. 1113 1114 Default_Namespaces : XML_NS; 1115 -- All the namespaces defined by default 1116 1117 Num_Toplevel_Elements : Natural; 1118 -- Number of elements at the toplevel 1119 1120 Element_Id : Natural := 0; 1121 -- Id of the current element. All elements created will have a 1122 -- different Id 1123 1124 Hooks : Parser_Hooks; 1125 -- Hooks to be called before the primitive operations 1126 1127 XML_Version : XML_Versions := XML_1_0_Fifth_Edition; 1128 1129 Standalone_Document : Boolean := False; 1130 -- Whether the document is specified as "standalone" in the XML 1131 -- prolog 1132 1133 Lookup_Char : Unicode.Unicode_Char := Unicode.Unicode_Char'Last; 1134 -- We can have a single forward lookup character, which is used to speed 1135 -- the parsing. 1136 1137 Last_Read : Unicode.Unicode_Char; 1138 Last_Read_Is_Valid : Boolean := True; 1139 -- Whether Last_Read is was actualy read, or whether it was set to null 1140 -- because we encountered the end of an input stream. 1141 -- (For instance, when an entity is parsed, its contents always ends 1142 -- with ASCII.NUL and Last_Read_Is_Valid is set to False. 1143 1144 State : Parser_State; 1145 1146 In_External_Entity : Boolean; 1147 -- Whether we are parsing an external entity 1148 1149 Previous_Char_Was_CR : Boolean; 1150 -- True if the previous character read from the stream was a 1151 -- Carriage_Return (needed since XML parsers must convert these to 1152 -- one single Line_Feed). 1153 1154 Ignore_State_Special : Boolean; 1155 -- If True, ignore the State.Ignore_Special flag in the next call 1156 -- to Next_Token. This is used for handling of special characters 1157 -- withing strings. 1158 1159 Basename_In_Messages : Boolean := False; 1160 -- If True, error messages are output with simple basenames for the 1161 -- files. This is required in a lot of cases because the message 1162 -- attached to an Ada exception is limited to 200 characters. 1163 1164 Feature_Namespace : Boolean := True; 1165 Feature_Namespace_Prefixes : Boolean := False; 1166 Feature_External_General_Entities : Boolean := True; 1167 Feature_External_Parameter_Entities : Boolean := True; 1168 Feature_Validation : Boolean := False; 1169 Feature_Test_Valid_Chars : Boolean := False; 1170 Feature_Schema_Validation : Boolean := True; 1171 Feature_Allow_Relative_IRI : Boolean := False; 1172 end record; 1173 1174 type Reader is new Sax_Reader with null record; 1175 1176end Sax.Readers; 1177