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