PageRenderTime 46ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/library/xslt/src/style/xm_xslt_output.e

http://github.com/gobo-eiffel/gobo
Specman e | 915 lines | 796 code | 65 blank | 54 comment | 90 complexity | e2833295f5dde899bced66764e26be37 MD5 | raw file
  1. note
  2. description:
  3. "xsl:output element nodes"
  4. library: "Gobo Eiffel XSLT Library"
  5. copyright: "Copyright (c) 2004-2018, Colin Adams and others"
  6. license: "MIT License"
  7. date: "$Date$"
  8. revision: "$Revision$"
  9. class XM_XSLT_OUTPUT
  10. inherit
  11. XM_XSLT_STYLE_ELEMENT
  12. redefine
  13. make_style_element, validate, is_output, as_output
  14. end
  15. XM_XSLT_OUTPUT_ROUTINES
  16. XM_UNICODE_CHARACTERS_1_1
  17. XM_XSLT_SHARED_EMITTER_FACTORY
  18. create {XM_XSLT_NODE_FACTORY}
  19. make_style_element
  20. feature {NONE} -- Initialization
  21. make_style_element (an_error_listener: XM_XSLT_ERROR_LISTENER; a_document: XM_XPATH_TREE_DOCUMENT; a_parent: detachable XM_XPATH_TREE_COMPOSITE_NODE;
  22. an_attribute_collection: detachable XM_XPATH_ATTRIBUTE_COLLECTION; a_namespace_list: detachable DS_ARRAYED_LIST [INTEGER];
  23. a_name_code: INTEGER; a_sequence_number: INTEGER; a_configuration: like configuration)
  24. -- Establish invariant.
  25. do
  26. create extension_attributes.make_with_equality_testers (1, string_equality_tester, string_equality_tester)
  27. Precursor (an_error_listener, a_document, a_parent, an_attribute_collection, a_namespace_list, a_name_code, a_sequence_number, a_configuration)
  28. end
  29. feature -- Access
  30. output_fingerprint: INTEGER
  31. -- Fingerprint of name
  32. feature -- Element change
  33. prepare_attributes
  34. -- Set the attribute list for the element.
  35. local
  36. l_cursor: DS_ARRAYED_LIST_CURSOR [INTEGER]
  37. a_name_code: INTEGER
  38. an_expanded_name, a_uri: STRING
  39. a_name_attribute: detachable STRING
  40. l_use_character_maps: like use_character_maps
  41. l_method: like method
  42. l_output_version: like output_version
  43. l_encoding: like encoding
  44. l_omit_xml_declaration: like omit_xml_declaration
  45. l_standalone: like standalone
  46. l_doctype_public: like doctype_public
  47. l_doctype_system: like doctype_system
  48. l_cdata_section_elements: like cdata_section_elements
  49. l_indent: like indent
  50. l_include_content_type: like include_content_type
  51. l_media_type: like media_type
  52. l_escape_uri_attributes: like escape_uri_attributes
  53. l_undeclare_prefixes: like undeclare_prefixes
  54. l_normalization_form: like normalization_form
  55. l_character_representation: like character_representation
  56. l_indent_spaces: like indent_spaces
  57. l_next_in_chain: like next_in_chain
  58. l_byte_order_mark: like byte_order_mark
  59. do
  60. if attached attribute_collection as l_attribute_collection then
  61. from
  62. l_cursor := l_attribute_collection.name_code_cursor
  63. l_cursor.start
  64. until
  65. l_cursor.after or any_compile_errors
  66. loop
  67. a_name_code := l_cursor.item
  68. an_expanded_name := shared_name_pool.expanded_name_from_name_code (a_name_code)
  69. if STRING_.same_string (an_expanded_name, Name_attribute) then
  70. a_name_attribute := attribute_value_by_index (l_cursor.index); STRING_.left_adjust (a_name_attribute); STRING_.right_adjust (a_name_attribute)
  71. elseif STRING_.same_string (an_expanded_name, Method_attribute) then
  72. l_method := attribute_value_by_index (l_cursor.index)
  73. STRING_.left_adjust (l_method)
  74. STRING_.right_adjust (l_method)
  75. method := l_method
  76. elseif STRING_.same_string (an_expanded_name, Version_attribute) then
  77. l_output_version := attribute_value_by_index (l_cursor.index)
  78. STRING_.left_adjust (l_output_version)
  79. STRING_.right_adjust (l_output_version)
  80. output_version := l_output_version
  81. elseif STRING_.same_string (an_expanded_name, Encoding_attribute) then
  82. l_encoding := attribute_value_by_index (l_cursor.index)
  83. STRING_.left_adjust (l_encoding)
  84. STRING_.right_adjust (l_encoding)
  85. encoding := l_encoding
  86. elseif STRING_.same_string (an_expanded_name, Omit_xml_declaration_attribute) then
  87. l_omit_xml_declaration := attribute_value_by_index (l_cursor.index)
  88. STRING_.left_adjust (l_omit_xml_declaration)
  89. STRING_.right_adjust (l_omit_xml_declaration)
  90. omit_xml_declaration := l_omit_xml_declaration
  91. elseif STRING_.same_string (an_expanded_name, Standalone_attribute) then
  92. l_standalone := attribute_value_by_index (l_cursor.index)
  93. STRING_.left_adjust (l_standalone)
  94. STRING_.right_adjust (l_standalone)
  95. standalone := l_standalone
  96. elseif STRING_.same_string (an_expanded_name, Doctype_public_attribute) then
  97. l_doctype_public := attribute_value_by_index (l_cursor.index)
  98. STRING_.left_adjust (l_doctype_public)
  99. STRING_.right_adjust (l_doctype_public)
  100. doctype_public := l_doctype_public
  101. elseif STRING_.same_string (an_expanded_name, Doctype_system_attribute) then
  102. l_doctype_system := attribute_value_by_index (l_cursor.index)
  103. STRING_.left_adjust (l_doctype_system)
  104. STRING_.right_adjust (l_doctype_system)
  105. doctype_system := l_doctype_system
  106. elseif STRING_.same_string (an_expanded_name, Cdata_section_elements_attribute) then
  107. l_cdata_section_elements := attribute_value_by_index (l_cursor.index)
  108. STRING_.left_adjust (l_cdata_section_elements)
  109. STRING_.right_adjust (l_cdata_section_elements)
  110. cdata_section_elements := l_cdata_section_elements
  111. elseif STRING_.same_string (an_expanded_name, Indent_attribute) then
  112. l_indent := attribute_value_by_index (l_cursor.index)
  113. STRING_.left_adjust (l_indent)
  114. STRING_.right_adjust (l_indent)
  115. indent := l_indent
  116. elseif STRING_.same_string (an_expanded_name, Include_content_type_attribute) then
  117. l_include_content_type := attribute_value_by_index (l_cursor.index)
  118. STRING_.left_adjust (l_include_content_type)
  119. STRING_.right_adjust (l_include_content_type)
  120. include_content_type := l_include_content_type
  121. elseif STRING_.same_string (an_expanded_name, Media_type_attribute) then
  122. l_media_type := attribute_value_by_index (l_cursor.index)
  123. STRING_.left_adjust (l_media_type)
  124. STRING_.right_adjust (l_media_type)
  125. media_type := l_media_type
  126. elseif STRING_.same_string (an_expanded_name, Escape_uri_attributes_attribute) then
  127. l_escape_uri_attributes := attribute_value_by_index (l_cursor.index)
  128. STRING_.left_adjust (l_escape_uri_attributes)
  129. STRING_.right_adjust (l_escape_uri_attributes)
  130. escape_uri_attributes := l_escape_uri_attributes
  131. elseif STRING_.same_string (an_expanded_name, Use_character_maps_attribute) then
  132. l_use_character_maps := attribute_value_by_index (l_cursor.index)
  133. STRING_.left_adjust (l_use_character_maps)
  134. STRING_.right_adjust (l_use_character_maps)
  135. use_character_maps := l_use_character_maps
  136. elseif STRING_.same_string (an_expanded_name, Undeclare_prefixes_attribute) then
  137. l_undeclare_prefixes := attribute_value_by_index (l_cursor.index)
  138. STRING_.left_adjust (l_undeclare_prefixes)
  139. STRING_.right_adjust (l_undeclare_prefixes)
  140. undeclare_prefixes := l_undeclare_prefixes
  141. elseif STRING_.same_string (an_expanded_name, Normalization_form_attribute) then
  142. l_normalization_form := attribute_value_by_index (l_cursor.index)
  143. STRING_.left_adjust (l_normalization_form)
  144. STRING_.right_adjust (l_normalization_form)
  145. normalization_form := l_normalization_form
  146. elseif STRING_.same_string (an_expanded_name, Gexslt_character_representation_attribute) then
  147. l_character_representation := attribute_value_by_index (l_cursor.index)
  148. STRING_.left_adjust (l_character_representation)
  149. STRING_.right_adjust (l_character_representation)
  150. character_representation := l_character_representation
  151. elseif STRING_.same_string (an_expanded_name, Gexslt_indent_spaces_attribute) then
  152. l_indent_spaces := attribute_value_by_index (l_cursor.index)
  153. STRING_.left_adjust (l_indent_spaces)
  154. STRING_.right_adjust (l_indent_spaces)
  155. indent_spaces := l_indent_spaces
  156. elseif STRING_.same_string (an_expanded_name, Gexslt_next_in_chain_attribute) then
  157. l_next_in_chain := attribute_value_by_index (l_cursor.index)
  158. STRING_.left_adjust (l_next_in_chain)
  159. STRING_.right_adjust (l_next_in_chain)
  160. next_in_chain := l_next_in_chain
  161. elseif STRING_.same_string (an_expanded_name, Byte_order_mark_attribute) then
  162. l_byte_order_mark := attribute_value_by_index (l_cursor.index)
  163. STRING_.left_adjust (l_byte_order_mark)
  164. STRING_.right_adjust (l_byte_order_mark)
  165. byte_order_mark := l_byte_order_mark
  166. else
  167. a_uri := shared_name_pool.namespace_uri_from_name_code (a_name_code)
  168. if a_uri.count = 0 or STRING_.same_string (a_uri, Xslt_uri) or STRING_.same_string (a_uri, Gexslt_eiffel_type_uri) then
  169. check_unknown_attribute (a_name_code)
  170. else
  171. extension_attributes.force (attribute_value_by_index (l_cursor.index), an_expanded_name)
  172. end
  173. end
  174. l_cursor.forth
  175. variant
  176. l_attribute_collection.number_of_attributes + 1 - l_cursor.index
  177. end
  178. end
  179. if a_name_attribute /= Void then
  180. generate_name_code (a_name_attribute)
  181. output_fingerprint := fingerprint_from_name_code (last_generated_name_code)
  182. else
  183. output_fingerprint := -1
  184. end
  185. attributes_prepared := True
  186. end
  187. validate
  188. -- Check that the stylesheet element is valid.
  189. local
  190. an_error: XM_XPATH_ERROR_VALUE
  191. l_message: STRING
  192. l_method_qname_parser: like method_qname_parser
  193. do
  194. check_top_level (Void)
  195. check_empty
  196. if attached output_version as l_output_version and then not is_nmtoken (l_output_version) then
  197. create an_error.make_from_string ("xsl:output 'version' attribute must be an 'nmtoken'", Xpath_errors_uri, "XTSE0110", Static_error)
  198. report_compile_error (an_error)
  199. end
  200. if attached method as l_method then
  201. if is_ncname (l_method) then
  202. if STRING_.same_string (l_method, "xml") or
  203. STRING_.same_string (l_method, "xhtml") or
  204. STRING_.same_string (l_method, "html") or
  205. STRING_.same_string (l_method, "text") then
  206. -- OK
  207. else
  208. create an_error.make_from_string ("xsl:output 'method' attribute must be a QName or one of 'xml', 'xhtml', 'html' or 'text'", Xpath_errors_uri, "XTSE1570", Static_error)
  209. report_compile_error (an_error)
  210. end
  211. elseif not is_qname (l_method) then
  212. create an_error.make_from_string ("xsl:output 'method' attribute must be a QName or one of 'xml', 'xhtml', 'html' or 'text'", Xpath_errors_uri, "XTSE1570", Static_error)
  213. report_compile_error (an_error)
  214. else
  215. create l_method_qname_parser.make (l_method)
  216. method_qname_parser := l_method_qname_parser
  217. if not l_method_qname_parser.is_valid then
  218. l_message := STRING_.concat (l_method, " is not a lexical QName.")
  219. create an_error.make_from_string (l_message, Xpath_errors_uri, "XTSE1570", Static_error)
  220. report_compile_error (an_error)
  221. else
  222. check
  223. attached l_method_qname_parser.optional_prefix as l_optional_prefix
  224. attached uri_for_prefix (l_optional_prefix, False) as l_uri_for_prefix
  225. attached l_method_qname_parser.local_name as l_local_name
  226. then
  227. if STRING_.same_string (l_uri_for_prefix, Gexslt_eiffel_type_uri)
  228. and STRING_.same_string (l_local_name, "chain") then
  229. is_chain := True
  230. end
  231. end
  232. end
  233. end
  234. end
  235. if is_chain and next_in_chain = Void then
  236. create an_error.make_from_string ("Output method gexslt:chain requires gexslt:next-in-chain attribute", Gexslt_eiffel_type_uri, "NEXT_IN_CHAIN_ABSENT", Static_error)
  237. report_compile_error (an_error)
  238. elseif not is_chain and next_in_chain /= Void then
  239. create an_error.make_from_string ("The gexslt:next-in-chain attribute is only permitted when the output method is gexslt:chian", Gexslt_eiffel_type_uri, "NEXT_IN_CHAIN_PRESENT", Static_error)
  240. report_compile_error (an_error)
  241. end
  242. if attached indent as l_indent then
  243. if STRING_.same_string (l_indent, "yes") or STRING_.same_string (l_indent, "no") then
  244. -- OK
  245. else
  246. create an_error.make_from_string ("indent must be 'yes' or 'no'", Xpath_errors_uri, "SEPM0016", Static_error)
  247. report_compile_error (an_error)
  248. end
  249. end
  250. if attached indent_spaces as l_indent_spaces then
  251. if not l_indent_spaces.is_integer then
  252. report_compile_warning (STRING_.concat (Gexslt_indent_spaces_attribute, " must be a strictly positive integer"))
  253. elseif l_indent_spaces.to_integer <= 0 then
  254. report_compile_warning (STRING_.concat (Gexslt_indent_spaces_attribute, " must be a strictly positive integer"))
  255. end
  256. end
  257. if attached omit_xml_declaration as l_omit_xml_declaration then
  258. if STRING_.same_string (l_omit_xml_declaration, "yes") or STRING_.same_string (l_omit_xml_declaration, "no") then
  259. -- OK
  260. else
  261. create an_error.make_from_string ("omit_xml_declaration must be 'yes' or 'no'", Xpath_errors_uri, "SEPM0016", Static_error)
  262. report_compile_error (an_error)
  263. end
  264. end
  265. if attached standalone as l_standalone then
  266. if STRING_.same_string (l_standalone, "yes") or STRING_.same_string (l_standalone, "no") or STRING_.same_string (l_standalone, "omit") then
  267. -- OK
  268. else
  269. create an_error.make_from_string ("standalone must be 'yes' or 'no'", Xpath_errors_uri, "SEPM0016", Static_error)
  270. report_compile_error (an_error)
  271. end
  272. end
  273. if attached cdata_section_elements as l_cdata_section_elements then
  274. check attached static_context as l_static_context then
  275. validate_cdata_sections (l_cdata_section_elements, l_static_context.namespace_resolver)
  276. end
  277. if attached cdata_validation_error as l_cdata_validation_error then
  278. report_compile_error (l_cdata_validation_error)
  279. end
  280. end
  281. if attached undeclare_prefixes as l_undeclare_prefixes then
  282. if STRING_.same_string (l_undeclare_prefixes, "yes") or STRING_.same_string (l_undeclare_prefixes, "no") then
  283. -- OK
  284. else
  285. create an_error.make_from_string ("undeclare-prefixes must be 'yes' or 'no'", Xpath_errors_uri, "SEPM0016", Static_error)
  286. report_compile_error (an_error)
  287. end
  288. end
  289. if attached normalization_form as l_normalization_form then
  290. if STRING_.same_string (l_normalization_form, "NFC") or STRING_.same_string (l_normalization_form, "NFD")
  291. or STRING_.same_string (l_normalization_form, "NFKC") or STRING_.same_string (l_normalization_form, "NFKD")
  292. or STRING_.same_string (l_normalization_form, "fully-normalized") or STRING_.same_string (l_normalization_form, "none")
  293. or is_nmtoken (l_normalization_form)
  294. then
  295. -- OK
  296. else
  297. create an_error.make_from_string ("normalization-form must be one of 'NFC', 'NFD', 'NFKC', 'NFKD', 'fully-normalized', 'none' or an NMTOKEN", Xpath_errors_uri, "SEPM0016", Static_error)
  298. report_compile_error (an_error)
  299. end
  300. end
  301. if attached include_content_type as l_include_content_type then
  302. if STRING_.same_string (l_include_content_type, "yes") or STRING_.same_string (l_include_content_type, "no") then
  303. -- OK
  304. else
  305. create an_error.make_from_string ("include-content-type must be 'yes' or 'no'", Xpath_errors_uri, "SEPM0016", Static_error)
  306. report_compile_error (an_error)
  307. end
  308. end
  309. if attached escape_uri_attributes as l_escape_uri_attributes then
  310. if STRING_.same_string (l_escape_uri_attributes, "yes") or STRING_.same_string (l_escape_uri_attributes, "no") then
  311. -- OK
  312. else
  313. create an_error.make_from_string ("escape-uri-attribute must be 'yes' or 'no'", Xpath_errors_uri, "SEPM0016", Static_error)
  314. report_compile_error (an_error)
  315. end
  316. end
  317. if attached byte_order_mark as l_byte_order_mark then
  318. if STRING_.same_string (l_byte_order_mark, "yes") or STRING_.same_string (l_byte_order_mark, "no") then
  319. -- OK
  320. else
  321. create an_error.make_from_string ("byte-order-mark must be 'yes' or 'no'", Xpath_errors_uri, "SEPM0016", Static_error)
  322. report_compile_error (an_error)
  323. end
  324. end
  325. validated := True
  326. end
  327. compile (an_executable: XM_XSLT_EXECUTABLE)
  328. -- Compile `Current' to an excutable instruction.
  329. do
  330. last_generated_expression := Void
  331. end
  332. gather_output_properties (a_property_set: XM_XSLT_OUTPUT_PROPERTIES)
  333. -- Accumulate output properties into `a_property_set'.
  334. require
  335. property_set_not_void: a_property_set /= Void
  336. property_set_not_in_error: not a_property_set.is_error
  337. validated: validated
  338. local
  339. l_import_precedence: INTEGER
  340. do
  341. l_import_precedence := precedence
  342. if method /= Void then
  343. gather_method_property (a_property_set, l_import_precedence)
  344. end
  345. if output_version /= Void and then not a_property_set.is_error then
  346. gather_version_property (a_property_set, l_import_precedence)
  347. end
  348. if indent /= Void and then not a_property_set.is_error then
  349. gather_indent_property (a_property_set, l_import_precedence)
  350. end
  351. if attached indent_spaces as l_indent_spaces and then not a_property_set.is_error and then l_indent_spaces.is_integer and then l_indent_spaces.to_integer > 0 then
  352. gather_indent_spaces_property (a_property_set, l_import_precedence)
  353. end
  354. if next_in_chain /= Void and then not a_property_set.is_error then
  355. gather_next_in_chain_property (a_property_set, l_import_precedence)
  356. end
  357. if encoding /= Void and then not a_property_set.is_error then
  358. gather_encoding_property (a_property_set, l_import_precedence)
  359. end
  360. if media_type /= Void and then not a_property_set.is_error then
  361. gather_media_type_property (a_property_set, l_import_precedence)
  362. end
  363. if doctype_system /= Void and then not a_property_set.is_error then
  364. gather_doctype_system_property (a_property_set, l_import_precedence)
  365. end
  366. if doctype_public /= Void and then not a_property_set.is_error then
  367. gather_doctype_public_property (a_property_set, l_import_precedence)
  368. end
  369. if omit_xml_declaration /= Void and then not a_property_set.is_error then
  370. gather_omit_xml_declaration_property (a_property_set, l_import_precedence)
  371. end
  372. if standalone /= Void and then not a_property_set.is_error then
  373. gather_standalone_property (a_property_set, l_import_precedence)
  374. end
  375. if attached cdata_section_expanded_names as l_cdata_section_expanded_names and then not a_property_set.is_error then
  376. a_property_set.set_cdata_sections (l_cdata_section_expanded_names)
  377. end
  378. if escape_uri_attributes /= Void and then not a_property_set.is_error then
  379. gather_escape_uri_attributes_property (a_property_set, l_import_precedence)
  380. end
  381. if use_character_maps /= Void and then not a_property_set.is_error then
  382. gather_used_character_maps_property (a_property_set, l_import_precedence)
  383. end
  384. if character_representation /= Void and then not a_property_set.is_error then
  385. gather_character_representation_property (a_property_set, l_import_precedence)
  386. end
  387. if include_content_type /= Void and then not a_property_set.is_error then
  388. gather_include_content_type_property (a_property_set, l_import_precedence)
  389. end
  390. if undeclare_prefixes /= Void and then not a_property_set.is_error then
  391. gather_undeclare_prefixes_property (a_property_set, l_import_precedence)
  392. end
  393. if normalization_form /= Void and then not a_property_set.is_error then
  394. gather_normalization_form_property (a_property_set, l_import_precedence)
  395. end
  396. if byte_order_mark /= Void and then not a_property_set.is_error then
  397. gather_byte_order_mark_property (a_property_set, l_import_precedence)
  398. end
  399. a_property_set.merge_extension_attributes (extension_attributes)
  400. end
  401. feature -- Conversion
  402. is_output: BOOLEAN
  403. -- Is `Current' an xsl:output?
  404. do
  405. Result := True
  406. end
  407. as_output: XM_XSLT_OUTPUT
  408. -- `Current' seen as an xsl:output
  409. do
  410. Result := Current
  411. end
  412. feature {NONE} -- Implementation
  413. method: detachable STRING
  414. -- method value
  415. output_version: detachable STRING
  416. -- version value
  417. encoding: detachable STRING
  418. -- encoding value
  419. omit_xml_declaration: detachable STRING
  420. -- omit-xml-declaration value
  421. standalone: detachable STRING
  422. -- standalone value
  423. doctype_public, doctype_system: detachable STRING
  424. -- DOCTYPE fpi and SYSTEM ids
  425. cdata_section_elements: detachable STRING
  426. -- cdata-section-elements value
  427. indent: detachable STRING
  428. -- indent value
  429. include_content_type: detachable STRING
  430. -- Include-content-type value
  431. media_type: detachable STRING
  432. -- media-type value
  433. escape_uri_attributes: detachable STRING
  434. -- escape-uri-attribute value
  435. undeclare_prefixes: detachable STRING
  436. -- undeclare-prefixes value
  437. normalization_form: detachable STRING
  438. -- normalization-form value
  439. character_representation: detachable STRING
  440. -- Extension attribute - character representation
  441. indent_spaces: detachable STRING
  442. -- Extension attribute - number of spaces to use when indent="yes"
  443. next_in_chain: detachable STRING
  444. -- URI of next stylesheet to be applied to output
  445. byte_order_mark: detachable STRING
  446. -- Do we write a byte order mark?
  447. extension_attributes: DS_HASH_TABLE [STRING, STRING]
  448. -- Extension attributs for use by QName methods
  449. is_chain: BOOLEAN
  450. -- Is `method' gexslt:chain?
  451. method_qname_parser: detachable XM_XPATH_QNAME_PARSER
  452. -- Parser for method name
  453. gather_method_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  454. -- Set method-related properties in `a_property_set'.
  455. require
  456. property_set_not_void: a_property_set /= Void
  457. property_set_not_in_error: not a_property_set.is_error
  458. validated: validated
  459. local
  460. l_uri: detachable STRING
  461. do
  462. check attached method as l_method then
  463. if STRING_.same_string (l_method, "xml") then
  464. if a_property_set.is_higher_precedence (a_import_precedence, Method_attribute) then
  465. a_property_set.set_xml_defaults (a_import_precedence)
  466. elseif not a_property_set.is_lower_precedence (a_import_precedence, Method_attribute) and then
  467. not STRING_.same_string (l_method, a_property_set.method) then
  468. a_property_set.set_duplication_error (Method_attribute)
  469. end
  470. elseif STRING_.same_string (l_method, "html") then
  471. if a_property_set.is_higher_precedence (a_import_precedence, Method_attribute) then
  472. a_property_set.set_html_defaults (a_import_precedence)
  473. elseif not a_property_set.is_lower_precedence (a_import_precedence, Method_attribute) and then
  474. not STRING_.same_string (l_method, a_property_set.method) then
  475. a_property_set.set_duplication_error (Method_attribute)
  476. end
  477. elseif STRING_.same_string (l_method, "xhtml") then
  478. if a_property_set.is_higher_precedence (a_import_precedence, Method_attribute) then
  479. a_property_set.set_xhtml_defaults (a_import_precedence)
  480. elseif not a_property_set.is_lower_precedence (a_import_precedence, Method_attribute) and then
  481. not STRING_.same_string (l_method, a_property_set.method) then
  482. a_property_set.set_duplication_error (Method_attribute)
  483. end
  484. elseif STRING_.same_string (l_method, "text") then
  485. if a_property_set.is_higher_precedence (a_import_precedence, Method_attribute) then
  486. a_property_set.set_text_defaults (a_import_precedence)
  487. elseif not a_property_set.is_lower_precedence (a_import_precedence, Method_attribute) and then
  488. not STRING_.same_string (l_method, a_property_set.method) then
  489. a_property_set.set_duplication_error (Method_attribute)
  490. end
  491. elseif not is_chain then
  492. check
  493. attached method_qname_parser as l_method_qname_parser
  494. attached l_method_qname_parser.optional_prefix as l_optional_prefix
  495. then
  496. l_uri := uri_for_prefix (l_optional_prefix, False)
  497. if l_uri = Void then
  498. report_compile_error (create {XM_XPATH_ERROR_VALUE}.make_from_string (STRING_.concat (l_optional_prefix, " is not an in-scope namespace prefix."), Xpath_errors_uri, "XTSE1570", Static_error))
  499. else
  500. check
  501. attached l_method_qname_parser.local_name as l_local_name
  502. then
  503. if emitter_factory.is_valid_output_method (l_uri, l_local_name) then
  504. if a_property_set.is_higher_precedence (a_import_precedence, Method_attribute) then
  505. emitter_factory.set_defaults (l_uri, l_local_name, a_property_set, a_import_precedence)
  506. elseif not a_property_set.is_lower_precedence (a_import_precedence, Method_attribute) and then
  507. not STRING_.same_string (l_method, a_property_set.method) then
  508. a_property_set.set_duplication_error (Method_attribute)
  509. end
  510. else
  511. report_compile_error (create {XM_XPATH_ERROR_VALUE}.make_from_string (STRING_.concat (l_method, " is not supported by this XSLT configuration/processor."), Xpath_errors_uri, "XTSE1570", Static_error))
  512. end
  513. end
  514. end
  515. end
  516. end
  517. end
  518. end
  519. gather_version_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  520. -- Set version property in `a_property_set'.
  521. require
  522. property_set_not_void: a_property_set /= Void
  523. property_set_not_in_error: not a_property_set.is_error
  524. validated: validated
  525. do
  526. if a_property_set.is_higher_precedence (a_import_precedence, Version_attribute) then
  527. check attached output_version as l_output_version then
  528. a_property_set.set_version (l_output_version, a_import_precedence)
  529. end
  530. else
  531. check attached output_version as l_output_version then
  532. if not a_property_set.is_lower_precedence (a_import_precedence, Version_attribute) and then
  533. not STRING_.same_string (l_output_version, a_property_set.version) then
  534. a_property_set.set_duplication_error (Version_attribute)
  535. end
  536. end
  537. end
  538. end
  539. gather_indent_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  540. -- Set indent property in `a_property_set'.
  541. require
  542. property_set_not_void: a_property_set /= Void
  543. property_set_not_in_error: not a_property_set.is_error
  544. validated: validated
  545. do
  546. if a_property_set.is_higher_precedence (a_import_precedence, Indent_attribute) then
  547. check attached indent as l_indent then
  548. a_property_set.set_indent (STRING_.same_string (l_indent, "yes"), a_import_precedence)
  549. end
  550. else
  551. check attached indent as l_indent then
  552. if not a_property_set.is_lower_precedence (a_import_precedence, Indent_attribute) and then
  553. ((STRING_.same_string (l_indent, "yes") and then not a_property_set.indent) or
  554. (STRING_.same_string (l_indent, "no") and then a_property_set.indent)) then
  555. a_property_set.set_duplication_error (Indent_attribute)
  556. end
  557. end
  558. end
  559. end
  560. gather_indent_spaces_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  561. -- Set indent-spaces property in `a_property_set'.
  562. require
  563. property_set_not_void: a_property_set /= Void
  564. property_set_not_in_error: not a_property_set.is_error
  565. validated: validated
  566. do
  567. if a_property_set.is_higher_precedence (a_import_precedence, Gexslt_indent_spaces_attribute) then
  568. check attached indent_spaces as l_indent_spaces then
  569. a_property_set.set_indent_spaces (l_indent_spaces.to_integer, a_import_precedence)
  570. end
  571. else
  572. check attached indent_spaces as l_indent_spaces then
  573. if not a_property_set.is_lower_precedence (a_import_precedence, Gexslt_indent_spaces_attribute) and then
  574. l_indent_spaces.to_integer /= a_property_set.indent_spaces then
  575. a_property_set.set_duplication_error (Gexslt_indent_spaces_attribute)
  576. end
  577. end
  578. end
  579. end
  580. gather_next_in_chain_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  581. -- Set next-in-chain property in `a_property_set'.
  582. require
  583. property_set_not_void: a_property_set /= Void
  584. property_set_not_in_error: not a_property_set.is_error
  585. validated: validated
  586. do
  587. if a_property_set.is_higher_precedence (a_import_precedence, Gexslt_next_in_chain_attribute) then
  588. check attached next_in_chain as l_next_in_chain then
  589. a_property_set.set_next_in_chain (l_next_in_chain, a_import_precedence)
  590. a_property_set.set_next_in_chain_base_uri (system_id)
  591. end
  592. elseif not a_property_set.is_lower_precedence (a_import_precedence, Gexslt_indent_spaces_attribute) then
  593. a_property_set.set_duplication_error (Gexslt_next_in_chain_attribute)
  594. end
  595. end
  596. gather_encoding_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  597. -- Set encoding property in `a_property_set'.
  598. require
  599. property_set_not_void: a_property_set /= Void
  600. property_set_not_in_error: not a_property_set.is_error
  601. validated: validated
  602. do
  603. if a_property_set.is_higher_precedence (a_import_precedence, Encoding_attribute) then
  604. check attached encoding as l_encoding then
  605. a_property_set.set_encoding (l_encoding, a_import_precedence)
  606. end
  607. else
  608. check attached encoding as l_encoding then
  609. if not a_property_set.is_lower_precedence (a_import_precedence, Encoding_attribute) and then
  610. not STRING_.same_string (l_encoding, a_property_set.encoding) then
  611. a_property_set.set_duplication_error (Encoding_attribute)
  612. end
  613. end
  614. end
  615. end
  616. gather_media_type_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  617. -- Set media-type property in `a_property_set'.
  618. require
  619. property_set_not_void: a_property_set /= Void
  620. property_set_not_in_error: not a_property_set.is_error
  621. validated: validated
  622. do
  623. if a_property_set.is_higher_precedence (a_import_precedence, Media_type_attribute) then
  624. check attached media_type as l_media_type then
  625. a_property_set.set_media_type (l_media_type, a_import_precedence)
  626. end
  627. else
  628. check attached media_type as l_media_type then
  629. if not a_property_set.is_lower_precedence (a_import_precedence, Media_type_attribute) and then
  630. not STRING_.same_string (l_media_type, a_property_set.media_type) then
  631. a_property_set.set_duplication_error (Media_type_attribute)
  632. end
  633. end
  634. end
  635. end
  636. gather_doctype_system_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  637. -- Set doctype-system property in `a_property_set'.
  638. require
  639. property_set_not_void: a_property_set /= Void
  640. property_set_not_in_error: not a_property_set.is_error
  641. validated: validated
  642. do
  643. if a_property_set.is_higher_precedence (a_import_precedence, Doctype_system_attribute) then
  644. check attached doctype_system as l_doctype_system then
  645. a_property_set.set_doctype_system (l_doctype_system, a_import_precedence)
  646. end
  647. else
  648. check
  649. attached doctype_system as l_doctype_system
  650. attached a_property_set.doctype_system as l_property_set_doctype_system
  651. then
  652. if not a_property_set.is_lower_precedence (a_import_precedence, Doctype_system_attribute) and then
  653. not STRING_.same_string (l_doctype_system, l_property_set_doctype_system) then
  654. a_property_set.set_duplication_error (Doctype_system_attribute)
  655. end
  656. end
  657. end
  658. end
  659. gather_doctype_public_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  660. -- Set doctype-public property in `a_property_set'.
  661. require
  662. property_set_not_void: a_property_set /= Void
  663. property_set_not_in_error: not a_property_set.is_error
  664. validated: validated
  665. do
  666. if a_property_set.is_higher_precedence (a_import_precedence, Doctype_public_attribute) then
  667. check attached doctype_public as l_doctype_public then
  668. a_property_set.set_doctype_public (l_doctype_public, a_import_precedence)
  669. end
  670. else
  671. check
  672. attached doctype_public as l_doctype_public
  673. attached a_property_set.doctype_public as l_property_set_doctype_public
  674. then
  675. if not a_property_set.is_lower_precedence (a_import_precedence, Doctype_public_attribute) and then
  676. not STRING_.same_string (l_doctype_public, l_property_set_doctype_public) then
  677. a_property_set.set_duplication_error (Doctype_public_attribute)
  678. end
  679. end
  680. end
  681. end
  682. gather_omit_xml_declaration_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  683. -- Set omit-xml-declaration property in `a_property_set'.
  684. require
  685. property_set_not_void: a_property_set /= Void
  686. property_set_not_in_error: not a_property_set.is_error
  687. validated: validated
  688. do
  689. if a_property_set.is_higher_precedence (a_import_precedence, Omit_xml_declaration_attribute) then
  690. check attached omit_xml_declaration as l_omit_xml_declaration then
  691. a_property_set.set_omit_xml_declaration (STRING_.same_string (l_omit_xml_declaration, "yes"), a_import_precedence)
  692. end
  693. elseif not a_property_set.is_lower_precedence (a_import_precedence, Omit_xml_declaration_attribute) then
  694. check attached omit_xml_declaration as l_omit_xml_declaration then
  695. if STRING_.same_string (l_omit_xml_declaration, "yes") and then not a_property_set.omit_xml_declaration or
  696. STRING_.same_string (l_omit_xml_declaration, "no") and then a_property_set.omit_xml_declaration then
  697. a_property_set.set_duplication_error (Omit_xml_declaration_attribute)
  698. end
  699. end
  700. end
  701. end
  702. gather_standalone_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  703. -- Set standalone property in `a_property_set'.
  704. require
  705. property_set_not_void: a_property_set /= Void
  706. property_set_not_in_error: not a_property_set.is_error
  707. validated: validated
  708. do
  709. if a_property_set.is_higher_precedence (a_import_precedence, Standalone_attribute) then
  710. check attached standalone as l_standalone then
  711. a_property_set.set_standalone (l_standalone, a_import_precedence)
  712. end
  713. else
  714. check
  715. attached standalone as l_standalone
  716. attached a_property_set.standalone as l_property_set_standalone
  717. then
  718. if not a_property_set.is_lower_precedence (a_import_precedence, Standalone_attribute) and then
  719. not STRING_.same_string (l_standalone, l_property_set_standalone) then
  720. a_property_set.set_duplication_error (Standalone_attribute)
  721. end
  722. end
  723. end
  724. end
  725. gather_escape_uri_attributes_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  726. -- Set escape-uri-attributes property in `a_property_set'.
  727. require
  728. property_set_not_void: a_property_set /= Void
  729. property_set_not_in_error: not a_property_set.is_error
  730. validated: validated
  731. do
  732. if a_property_set.is_higher_precedence (a_import_precedence, Escape_uri_attributes_attribute) then
  733. check attached escape_uri_attributes as l_escape_uri_attributes then
  734. a_property_set.set_escape_uri_attributes (STRING_.same_string (l_escape_uri_attributes, "yes"), a_import_precedence)
  735. end
  736. elseif not a_property_set.is_lower_precedence (a_import_precedence, Escape_uri_attributes_attribute) then
  737. check attached escape_uri_attributes as l_escape_uri_attributes then
  738. if STRING_.same_string (l_escape_uri_attributes, "yes") and then not a_property_set.escape_uri_attributes or
  739. STRING_.same_string (l_escape_uri_attributes, "no") and then a_property_set.escape_uri_attributes then
  740. a_property_set.set_duplication_error (Escape_uri_attributes_attribute)
  741. end
  742. end
  743. end
  744. end
  745. gather_character_representation_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  746. -- Set character-representation property in `a_property_set'.
  747. require
  748. property_set_not_void: a_property_set /= Void
  749. property_set_not_in_error: not a_property_set.is_error
  750. validated: validated
  751. do
  752. check attached character_representation as l_character_representation then
  753. if a_property_set.is_valid_character_representation (l_character_representation) then
  754. if a_property_set.is_higher_precedence (a_import_precedence, Gexslt_character_representation_attribute) then
  755. a_property_set.set_character_representation (l_character_representation, a_import_precedence)
  756. elseif not a_property_set.is_lower_precedence (a_import_precedence, Gexslt_character_representation_attribute) and then
  757. not STRING_.same_string (l_character_representation, a_property_set.character_representation) then
  758. a_property_set.set_duplication_error (Gexslt_character_representation_attribute)
  759. end
  760. else
  761. report_compile_warning (STRING_.concat (l_character_representation, " is not a valid value for gexslt:character-representation"))
  762. end
  763. end
  764. end
  765. gather_include_content_type_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  766. -- Set include-content-type property in `a_property_set'.
  767. require
  768. property_set_not_void: a_property_set /= Void
  769. property_set_not_in_error: not a_property_set.is_error
  770. validated: validated
  771. do
  772. if a_property_set.is_higher_precedence (a_import_precedence, Include_content_type_attribute) then
  773. check attached include_content_type as l_include_content_type then
  774. a_property_set.set_include_content_type (STRING_.same_string (l_include_content_type, "yes"), a_import_precedence)
  775. end
  776. elseif not a_property_set.is_lower_precedence (a_import_precedence, Include_content_type_attribute) then
  777. check attached include_content_type as l_include_content_type then
  778. if STRING_.same_string (l_include_content_type, "yes") and then not a_property_set.include_content_type or
  779. STRING_.same_string (l_include_content_type, "no") and then a_property_set.include_content_type then
  780. a_property_set.set_duplication_error (Include_content_type_attribute)
  781. end
  782. end
  783. end
  784. end
  785. gather_undeclare_prefixes_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  786. -- Set undeclare-prefixes property in `a_property_set'.
  787. require
  788. property_set_not_void: a_property_set /= Void
  789. property_set_not_in_error: not a_property_set.is_error
  790. validated: validated
  791. do
  792. if a_property_set.is_higher_precedence (a_import_precedence, Undeclare_prefixes_attribute) then
  793. check attached undeclare_prefixes as l_undeclare_prefixes then
  794. a_property_set.set_undeclare_prefixes (STRING_.same_string (l_undeclare_prefixes, "yes"), a_import_precedence)
  795. end
  796. elseif not a_property_set.is_lower_precedence (a_import_precedence, Undeclare_prefixes_attribute) then
  797. check attached undeclare_prefixes as l_undeclare_prefixes then
  798. if STRING_.same_string (l_undeclare_prefixes, "yes") and then not a_property_set.undeclare_prefixes or
  799. STRING_.same_string (l_undeclare_prefixes, "no") and then a_property_set.undeclare_prefixes then
  800. a_property_set.set_duplication_error (Undeclare_prefixes_attribute)
  801. end
  802. end
  803. end
  804. end
  805. gather_normalization_form_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  806. -- Set normalization-form property in `a_property_set'.
  807. require
  808. property_set_not_void: a_property_set /= Void
  809. property_set_not_in_error: not a_property_set.is_error
  810. validated: validated
  811. do
  812. if a_property_set.is_higher_precedence (a_import_precedence, Normalization_form_attribute) then
  813. check attached normalization_form as l_normalization_form then
  814. a_property_set.set_normalization_form (l_normalization_form, a_import_precedence)
  815. end
  816. else
  817. check
  818. attached normalization_form as l_normalization_form
  819. attached a_property_set.normalization_form as l_property_set_normalization_form
  820. then
  821. if not a_property_set.is_lower_precedence (a_import_precedence, Normalization_form_attribute)
  822. and then not STRING_.same_string (l_normalization_form, l_property_set_normalization_form) then
  823. a_property_set.set_duplication_error (Normalization_form_attribute)
  824. end
  825. end
  826. end
  827. end
  828. gather_byte_order_mark_property (a_property_set: XM_XSLT_OUTPUT_PROPERTIES; a_import_precedence: INTEGER)
  829. -- Set byte-order-form property in `a_property_set'.
  830. require
  831. property_set_not_void: a_property_set /= Void
  832. property_set_not_in_error: not a_property_set.is_error
  833. validated: validated
  834. do
  835. if a_property_set.is_higher_precedence (a_import_precedence, Byte_order_mark_attribute) then
  836. check attached byte_order_mark as l_byte_order_mark then
  837. a_property_set.set_byte_order_mark_required (STRING_.same_string (l_byte_order_mark, "yes"), a_import_precedence)
  838. end
  839. elseif not a_property_set.is_lower_precedence (a_import_precedence, Byte_order_mark_attribute) then
  840. check attached byte_order_mark as l_byte_order_mark then
  841. if STRING_.same_string (l_byte_order_mark, "yes") and then not a_property_set.byte_order_mark_required or
  842. STRING_.same_string (l_byte_order_mark, "no") and then a_property_set.byte_order_mark_required then
  843. a_property_set.set_duplication_error (Byte_order_mark_attribute)
  844. end
  845. end
  846. end
  847. end
  848. invariant
  849. extension_attributes_not_void: extension_attributes /= Void
  850. end