/src/lib/xml/xml_callbacks.e

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