/src/lib/xml/xml_callbacks.e
Specman e | 142 lines | 74 code | 16 blank | 52 comment | 0 complexity | 859d82dca936c0350b8a3ddfc096ae81 MD5 | raw file
1-- See the Copyright notice at the end of this file. 2-- 3deferred class XML_CALLBACKS 4 -- 5 -- Catch parsing events sent by the XML parser. 6 -- 7 -- '''Caveat:''' expect those features to always receive the same UNICODE_STRING object with different 8 -- values. You should take care of twinning the object if you want to keep it. 9 -- 10 -- See also XML_PARSER 11 -- 12 13feature {XML_PARSER} 14 set_validator (a_validator: like validator) 15 -- Sets a validator for this XML file. The parser uses it when setting a DTD, but you may use it too 16 -- to implement other validators (such as an XML Schema). 17 require 18 validator = Void 19 a_validator /= Void 20 do 21 validator := a_validator 22 ensure 23 validator = a_validator 24 end 25 26 validator: XML_VALIDATOR 27 -- The XML validator for this file (DTD, XML Schema...) 28 29 with_attribute (attribute_name: UNICODE_STRING; attribute_value: UNICODE_STRING; line, column: INTEGER) 30 -- Called by the parser to add an attribute of a node BEFORE calling `open_node' 31 require 32 not attribute_name.is_empty 33 attribute_value /= Void 34 deferred 35 end 36 37 open_node (node_name: UNICODE_STRING; line, column: INTEGER) 38 -- When the parser reads an opening node 39 require 40 not node_name.is_empty 41 deferred 42 ensure 43 not at_error implies current_node.is_equal(node_name) 44 end 45 46 close_node (node_name: UNICODE_STRING; line, column: INTEGER) 47 -- When the parser reads a closing node 48 require 49 not node_name.is_empty 50 current_node.is_equal(node_name) 51 deferred 52 end 53 54 open_close_node (node_name: UNICODE_STRING; line, column: INTEGER) 55 -- When the parser reads a node that opens and closes immediately (syntax "<node/>") 56 require 57 not node_name.is_empty 58 deferred 59 end 60 61 xml_header (line, column: INTEGER) 62 -- Called by the parser if a "<?xml ... ?>" header is read. 63 -- Note that with_attribute may have been called first (usually with the version and encoding 64 -- attributes) 65 deferred 66 end 67 68 processing_instruction (a_target, a_data: UNICODE_STRING) 69 -- Called by the parser if a "<?...?>" processing instruction is read. 70 deferred 71 end 72 73 entity (a_entity: UNICODE_STRING; line, column: INTEGER): UNICODE_STRING 74 -- Called by the parser when an '''&entity;''' is found. Note that standard XML attributes (''lt'', 75 -- ''gt'', ''amp'', ''apos'' and ''quot'') are automatically handled and not given to this feature 76 -- (they cannot be bypassed). 77 -- Returns Void if the entity is not recognized. 78 deferred 79 end 80 81 open_entity_url (a_entity: UNICODE_STRING; a_url: URL) 82 -- Called by the parser when the entity triggers the reading of another stream (i.e. a SYSTEM or 83 -- PUBLIC entity) 84 require 85 a_url /= Void 86 deferred 87 end 88 89 close_entity_url (a_entity: UNICODE_STRING; a_url: URL) 90 -- Called by the parser when the stream triggered by `open_entity_url' is disconnected 91 require 92 a_url /= Void 93 deferred 94 end 95 96 current_node: UNICODE_STRING 97 -- The current node 98 deferred 99 end 100 101 data (a_data: UNICODE_STRING; line, column: INTEGER) 102 -- Called by the parser when the node contains raw data 103 require 104 not a_data.is_empty 105 deferred 106 end 107 108 parse_error (line, column: INTEGER; message: STRING) 109 -- Called by the parser if there is an error 110 require 111 message /= Void 112 deferred 113 ensure 114 at_error 115 end 116 117 at_error: BOOLEAN 118 -- True if there was at least an error 119 deferred 120 end 121 122end -- class XML_CALLBACKS 123-- 124-- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file. 125-- 126-- Permission is hereby granted, free of charge, to any person obtaining a copy 127-- of this software and associated documentation files (the "Software"), to deal 128-- in the Software without restriction, including without limitation the rights 129-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 130-- copies of the Software, and to permit persons to whom the Software is 131-- furnished to do so, subject to the following conditions: 132-- 133-- The above copyright notice and this permission notice shall be included in 134-- all copies or substantial portions of the Software. 135-- 136-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 137-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 138-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 139-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 140-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 141-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 142-- THE SOFTWARE.