1------------------------------------------------------------------------------ 2-- -- 3-- Matreshka Project -- 4-- -- 5-- XML Processor -- 6-- -- 7-- Runtime Library Component -- 8-- -- 9------------------------------------------------------------------------------ 10-- -- 11-- Copyright © 2010-2014, Vadim Godunko <vgodunko@gmail.com> -- 12-- All rights reserved. -- 13-- -- 14-- Redistribution and use in source and binary forms, with or without -- 15-- modification, are permitted provided that the following conditions -- 16-- are met: -- 17-- -- 18-- * Redistributions of source code must retain the above copyright -- 19-- notice, this list of conditions and the following disclaimer. -- 20-- -- 21-- * Redistributions in binary form must reproduce the above copyright -- 22-- notice, this list of conditions and the following disclaimer in the -- 23-- documentation and/or other materials provided with the distribution. -- 24-- -- 25-- * Neither the name of the Vadim Godunko, IE nor the names of its -- 26-- contributors may be used to endorse or promote products derived from -- 27-- this software without specific prior written permission. -- 28-- -- 29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- 30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- 31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- 32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- 33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- 34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- 35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- 36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- 37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- 38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- 39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- 40-- -- 41------------------------------------------------------------------------------ 42-- $Revision: 4777 $ $Date: 2014-03-29 11:52:24 +0400 (Sat, 29 Mar 2014) $ 43------------------------------------------------------------------------------ 44with XML.SAX.Simple_Readers.Callbacks; 45 46package body XML.SAX.Simple_Readers.Analyzer is 47 48 use Matreshka.Internals.XML; 49 use Matreshka.Internals.XML.Element_Tables; 50 use Matreshka.Internals.XML.Entity_Tables; 51 use Matreshka.Internals.XML.Symbol_Tables; 52 53 --------------------------------------- 54 -- Analyze_Document_Type_Declaration -- 55 --------------------------------------- 56 57 procedure Analyze_Document_Type_Declaration 58 (Self : in out Simple_Reader'Class) 59 is 60 Current : Entity_Identifier; 61 Current_Element : Element_Identifier; 62 63 begin 64 if Self.Validation.Enabled then 65 Current := First_Entity (Self.Entities); 66 67 while Current /= No_Entity loop 68 -- [XML 4.2.2 VC: Notation Declared] 69 -- 70 -- "The Name MUST match the declared name of a notation." 71 -- 72 -- Check whether entity is unparsed and its notation is declared. 73 74 if Is_External_Unparsed_General_Entity (Self.Entities, Current) 75 and then Symbol_Tables.Notation 76 (Self.Symbols, 77 Notation (Self.Entities, Current)) = No_Notation 78 then 79 Callbacks.Call_Error 80 (Self, 81 League.Strings.To_Universal_String 82 ("[XML 4.2.2 VC: Notation Declared]" 83 & " notation name must match the declared name of a" 84 & " notation")); 85 end if; 86 87 Next_Entity (Self.Entities, Current); 88 end loop; 89 end if; 90 91 -- [XML 3.3] Attribute List Declaration 92 -- 93 -- "The Name in the AttlistDecl rule is the type of an element. At user 94 -- option, an XML processor MAY issue a warning if attributes are 95 -- declared for an element type not itself declared, but this is not an 96 -- error. The Name in the AttDef rule is the name of the attribute." 97 -- 98 -- Check whether element is not declared and has declared attributes. 99 100 Current_Element := First_Element (Self.Elements); 101 102 while Current_Element /= No_Element loop 103 if not Is_Declared (Self.Elements, Current_Element) 104 and Is_Attributes_Declared (Self.Elements, Current_Element) 105 then 106 Callbacks.Call_Warning 107 (Self, 108 League.Strings.To_Universal_String 109 ("[XML 3.3]" 110 & " attribute list declaration for element type not itself" 111 & " declared")); 112 end if; 113 114 Next_Element (Self.Elements, Current_Element); 115 end loop; 116 end Analyze_Document_Type_Declaration; 117 118end XML.SAX.Simple_Readers.Analyzer; 119