PageRenderTime 59ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/library/xslt/test/unit/xm_xslt_test_variables.e

http://github.com/gobo-eiffel/gobo
Specman e | 965 lines | 836 code | 74 blank | 55 comment | 0 complexity | ef9ea3536cacf052af5aa8452186db72 MD5 | raw file
  1. note
  2. description:
  3. "Test the XSLT variables and parameters"
  4. library: "Gobo Eiffel XSLT test suite"
  5. copyright: "Copyright (c) 2005-2018, Colin Adams and others"
  6. license: "MIT License"
  7. date: "$Date$"
  8. revision: "$Revision$"
  9. class XM_XSLT_TEST_VARIABLES
  10. inherit
  11. TS_TEST_CASE
  12. KL_IMPORTED_STRING_ROUTINES
  13. XM_XPATH_SHARED_CONFORMANCE
  14. XM_XSLT_CONFIGURATION_CONSTANTS
  15. XM_XPATH_SHARED_NAME_POOL
  16. XM_RESOLVER_FACTORY
  17. XM_XPATH_STANDARD_NAMESPACES
  18. create
  19. make_default
  20. feature -- Test
  21. test_range_variable_in_global_variable
  22. -- Test use of range variables within the select expression of a global variable.
  23. local
  24. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  25. l_configuration: XM_XSLT_CONFIGURATION
  26. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  27. l_transformer: detachable XM_XSLT_TRANSFORMER
  28. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  29. l_output: XM_OUTPUT
  30. l_result: XM_XSLT_TRANSFORMATION_RESULT
  31. l_last_output: detachable STRING
  32. do
  33. conformance.set_basic_xslt_processor
  34. create l_configuration.make_with_defaults
  35. create l_error_listener.make (l_configuration.recovery_policy)
  36. l_configuration.set_error_listener (l_error_listener)
  37. l_configuration.set_line_numbering (True)
  38. create l_transformer_factory.make (l_configuration)
  39. create l_uri_source.make (var15_xsl_uri.full_reference)
  40. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  41. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  42. l_transformer := l_transformer_factory.created_transformer
  43. assert ("transformer", l_transformer /= Void)
  44. check asserted_above: l_transformer /= Void then end
  45. assert ("transformer", l_transformer /= Void)
  46. create l_second_uri_source.make (var25_xml_uri.full_reference)
  47. create l_output
  48. l_output.set_output_to_string
  49. create l_result.make (l_output, "string:")
  50. l_transformer.transform (l_second_uri_source, l_result)
  51. assert ("Transform successful", not l_transformer.is_error)
  52. l_last_output := l_output.last_output
  53. assert ("set_output_to_string", l_last_output /= Void)
  54. check asserted_above: l_last_output /= Void then end
  55. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_eight))
  56. end
  57. test_type_conversion_on_apply
  58. -- Test type conversion of parameters in an xsl:apply-templates call.
  59. local
  60. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  61. l_configuration: XM_XSLT_CONFIGURATION
  62. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  63. l_transformer: detachable XM_XSLT_TRANSFORMER
  64. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  65. l_output: XM_OUTPUT
  66. l_result: XM_XSLT_TRANSFORMATION_RESULT
  67. l_last_output: detachable STRING
  68. do
  69. conformance.set_basic_xslt_processor
  70. create l_configuration.make_with_defaults
  71. create l_error_listener.make (l_configuration.recovery_policy)
  72. l_configuration.set_error_listener (l_error_listener)
  73. l_configuration.set_line_numbering (True)
  74. create l_transformer_factory.make (l_configuration)
  75. create l_uri_source.make (var16_xsl_uri.full_reference)
  76. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  77. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  78. l_transformer := l_transformer_factory.created_transformer
  79. assert ("transformer", l_transformer /= Void)
  80. check asserted_above: l_transformer /= Void then end
  81. create l_second_uri_source.make (var25_xml_uri.full_reference)
  82. create l_output
  83. l_output.set_output_to_string
  84. create l_result.make (l_output, "string:")
  85. l_transformer.transform (l_second_uri_source, l_result)
  86. assert ("Transform successful", not l_transformer.is_error)
  87. l_last_output := l_output.last_output
  88. assert ("set_output_to_string", l_last_output /= Void)
  89. check asserted_above: l_last_output /= Void then end
  90. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_seven))
  91. end
  92. test_as_attribute_on_with_param
  93. -- Test as attribute on xsl:with-param.
  94. local
  95. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  96. l_configuration: XM_XSLT_CONFIGURATION
  97. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  98. l_transformer: detachable XM_XSLT_TRANSFORMER
  99. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  100. l_output: XM_OUTPUT
  101. l_result: XM_XSLT_TRANSFORMATION_RESULT
  102. l_last_output: detachable STRING
  103. do
  104. conformance.set_basic_xslt_processor
  105. create l_configuration.make_with_defaults
  106. create l_error_listener.make (l_configuration.recovery_policy)
  107. l_configuration.set_error_listener (l_error_listener)
  108. l_configuration.set_line_numbering (True)
  109. create l_transformer_factory.make (l_configuration)
  110. create l_uri_source.make (var17_xsl_uri.full_reference)
  111. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  112. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  113. l_transformer := l_transformer_factory.created_transformer
  114. assert ("transformer", l_transformer /= Void)
  115. check asserted_above: l_transformer /= Void then end
  116. create l_second_uri_source.make (var25_xml_uri.full_reference)
  117. create l_output
  118. l_output.set_output_to_string
  119. create l_result.make (l_output, "string:")
  120. l_transformer.transform (l_second_uri_source, l_result)
  121. assert ("Transform successful", not l_transformer.is_error)
  122. l_last_output := l_output.last_output
  123. assert ("set_output_to_string", l_last_output /= Void)
  124. check asserted_above: l_last_output /= Void then end
  125. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_six))
  126. end
  127. test_tunnel_parameters
  128. -- Basic test of tunnel parameters.
  129. local
  130. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  131. l_configuration: XM_XSLT_CONFIGURATION
  132. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  133. l_transformer: detachable XM_XSLT_TRANSFORMER
  134. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  135. l_output: XM_OUTPUT
  136. l_result: XM_XSLT_TRANSFORMATION_RESULT
  137. l_last_output: detachable STRING
  138. do
  139. conformance.set_basic_xslt_processor
  140. create l_configuration.make_with_defaults
  141. create l_error_listener.make (l_configuration.recovery_policy)
  142. l_configuration.set_error_listener (l_error_listener)
  143. l_configuration.set_line_numbering (True)
  144. create l_transformer_factory.make (l_configuration)
  145. create l_uri_source.make (var20_xsl_uri.full_reference)
  146. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  147. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  148. l_transformer := l_transformer_factory.created_transformer
  149. assert ("transformer", l_transformer /= Void)
  150. check asserted_above: l_transformer /= Void then end
  151. create l_second_uri_source.make (var20_xml_uri.full_reference)
  152. create l_output
  153. l_output.set_output_to_string
  154. create l_result.make (l_output, "string:")
  155. l_transformer.transform (l_second_uri_source, l_result)
  156. assert ("Transform successful", not l_transformer.is_error)
  157. l_last_output := l_output.last_output
  158. assert ("set_output_to_string", l_last_output /= Void)
  159. check asserted_above: l_last_output /= Void then end
  160. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_one))
  161. end
  162. test_override_tunnel_parameter
  163. -- Test overriding a tunnel parameter.
  164. local
  165. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  166. l_configuration: XM_XSLT_CONFIGURATION
  167. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  168. l_transformer: detachable XM_XSLT_TRANSFORMER
  169. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  170. l_output: XM_OUTPUT
  171. l_result: XM_XSLT_TRANSFORMATION_RESULT
  172. l_last_output: detachable STRING
  173. do
  174. conformance.set_basic_xslt_processor
  175. create l_configuration.make_with_defaults
  176. create l_error_listener.make (l_configuration.recovery_policy)
  177. l_configuration.set_error_listener (l_error_listener)
  178. l_configuration.set_line_numbering (True)
  179. create l_transformer_factory.make (l_configuration)
  180. create l_uri_source.make (var21_xsl_uri.full_reference)
  181. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  182. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  183. l_transformer := l_transformer_factory.created_transformer
  184. assert ("transformer", l_transformer /= Void)
  185. check asserted_above: l_transformer /= Void then end
  186. create l_second_uri_source.make (var20_xml_uri.full_reference)
  187. create l_output
  188. l_output.set_output_to_string
  189. create l_result.make (l_output, "string:")
  190. l_transformer.transform (l_second_uri_source, l_result)
  191. assert ("Transform successful", not l_transformer.is_error)
  192. l_last_output := l_output.last_output
  193. assert ("set_output_to_string", l_last_output /= Void)
  194. check asserted_above: l_last_output /= Void then end
  195. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_two))
  196. end
  197. test_tunnel_parameters_with_call_template
  198. -- Test tunnel parameters with xsl:call-template.
  199. local
  200. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  201. l_configuration: XM_XSLT_CONFIGURATION
  202. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  203. l_transformer: detachable XM_XSLT_TRANSFORMER
  204. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  205. l_output: XM_OUTPUT
  206. l_result: XM_XSLT_TRANSFORMATION_RESULT
  207. l_last_output: detachable STRING
  208. do
  209. conformance.set_basic_xslt_processor
  210. create l_configuration.make_with_defaults
  211. create l_error_listener.make (l_configuration.recovery_policy)
  212. l_configuration.set_error_listener (l_error_listener)
  213. l_configuration.set_line_numbering (True)
  214. create l_transformer_factory.make (l_configuration)
  215. create l_uri_source.make (var21_xsl_uri.full_reference)
  216. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  217. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  218. l_transformer := l_transformer_factory.created_transformer
  219. assert ("transformer", l_transformer /= Void)
  220. check asserted_above: l_transformer /= Void then end
  221. create l_second_uri_source.make (var20_xml_uri.full_reference)
  222. create l_output
  223. l_output.set_output_to_string
  224. create l_result.make (l_output, "string:")
  225. l_transformer.transform (l_second_uri_source, l_result)
  226. assert ("Transform successful", not l_transformer.is_error)
  227. l_last_output := l_output.last_output
  228. assert ("set_output_to_string", l_last_output /= Void)
  229. check asserted_above: l_last_output /= Void then end
  230. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_two))
  231. end
  232. test_normal_versus_tunnel_parameters
  233. -- Test normal parameters not clashing with tunnel parameters.
  234. local
  235. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  236. l_configuration: XM_XSLT_CONFIGURATION
  237. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  238. l_transformer: detachable XM_XSLT_TRANSFORMER
  239. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  240. l_output: XM_OUTPUT
  241. l_result: XM_XSLT_TRANSFORMATION_RESULT
  242. l_last_output: detachable STRING
  243. do
  244. conformance.set_basic_xslt_processor
  245. create l_configuration.make_with_defaults
  246. create l_error_listener.make (l_configuration.recovery_policy)
  247. l_configuration.set_error_listener (l_error_listener)
  248. l_configuration.set_line_numbering (True)
  249. create l_transformer_factory.make (l_configuration)
  250. create l_uri_source.make (var23_xsl_uri.full_reference)
  251. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  252. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  253. l_transformer := l_transformer_factory.created_transformer
  254. assert ("transformer", l_transformer /= Void)
  255. check asserted_above: l_transformer /= Void then end
  256. create l_second_uri_source.make (var20_xml_uri.full_reference)
  257. create l_output
  258. l_output.set_output_to_string
  259. create l_result.make (l_output, "string:")
  260. l_transformer.transform (l_second_uri_source, l_result)
  261. assert ("Transform successful", not l_transformer.is_error)
  262. l_last_output := l_output.last_output
  263. assert ("set_output_to_string", l_last_output /= Void)
  264. check asserted_above: l_last_output /= Void then end
  265. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_three))
  266. end
  267. test_tunnel_parameters_with_variable_contents
  268. -- Test tunnel parameters passed to match on variable contents.
  269. local
  270. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  271. l_configuration: XM_XSLT_CONFIGURATION
  272. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  273. l_transformer: detachable XM_XSLT_TRANSFORMER
  274. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  275. l_output: XM_OUTPUT
  276. l_result: XM_XSLT_TRANSFORMATION_RESULT
  277. l_last_output: detachable STRING
  278. do
  279. conformance.set_basic_xslt_processor
  280. create l_configuration.make_with_defaults
  281. create l_error_listener.make (l_configuration.recovery_policy)
  282. l_configuration.set_error_listener (l_error_listener)
  283. l_configuration.set_line_numbering (True)
  284. create l_transformer_factory.make (l_configuration)
  285. create l_uri_source.make (var25_xsl_uri.full_reference)
  286. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  287. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  288. l_transformer := l_transformer_factory.created_transformer
  289. assert ("transformer", l_transformer /= Void)
  290. check asserted_above: l_transformer /= Void then end
  291. create l_second_uri_source.make (var25_xml_uri.full_reference)
  292. create l_output
  293. l_output.set_output_to_string
  294. create l_result.make (l_output, "string:")
  295. l_transformer.transform (l_second_uri_source, l_result)
  296. assert ("Transform successful", not l_transformer.is_error)
  297. l_last_output := l_output.last_output
  298. assert ("set_output_to_string", l_last_output /= Void)
  299. check asserted_above: l_last_output /= Void then end
  300. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_four))
  301. end
  302. test_supplied_tunnel_parameter
  303. -- Test supplied tunnel parameter.
  304. local
  305. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  306. l_configuration: XM_XSLT_CONFIGURATION
  307. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  308. l_transformer: detachable XM_XSLT_TRANSFORMER
  309. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  310. l_output: XM_OUTPUT
  311. l_result: XM_XSLT_TRANSFORMATION_RESULT
  312. l_last_output: detachable STRING
  313. do
  314. conformance.set_basic_xslt_processor
  315. create l_configuration.make_with_defaults
  316. create l_error_listener.make (l_configuration.recovery_policy)
  317. l_configuration.set_error_listener (l_error_listener)
  318. l_configuration.set_line_numbering (True)
  319. create l_transformer_factory.make (l_configuration)
  320. create l_uri_source.make (var26_xsl_uri.full_reference)
  321. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  322. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  323. l_transformer := l_transformer_factory.created_transformer
  324. assert ("transformer", l_transformer /= Void)
  325. check asserted_above: l_transformer /= Void then end
  326. create l_second_uri_source.make (var25_xml_uri.full_reference)
  327. create l_output
  328. l_output.set_output_to_string
  329. create l_result.make (l_output, "string:")
  330. l_transformer.transform (l_second_uri_source, l_result)
  331. assert ("Transform successful", not l_transformer.is_error)
  332. l_last_output := l_output.last_output
  333. assert ("set_output_to_string", l_last_output /= Void)
  334. check asserted_above: l_last_output /= Void then end
  335. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_five))
  336. end
  337. test_supplied_required_tunnel_parameter
  338. -- Test supplied required tunnel parameter.
  339. local
  340. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  341. l_configuration: XM_XSLT_CONFIGURATION
  342. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  343. l_transformer: detachable XM_XSLT_TRANSFORMER
  344. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  345. l_output: XM_OUTPUT
  346. l_result: XM_XSLT_TRANSFORMATION_RESULT
  347. l_last_output: detachable STRING
  348. do
  349. conformance.set_basic_xslt_processor
  350. create l_configuration.make_with_defaults
  351. create l_error_listener.make (l_configuration.recovery_policy)
  352. l_configuration.set_error_listener (l_error_listener)
  353. l_configuration.set_line_numbering (True)
  354. create l_transformer_factory.make (l_configuration)
  355. create l_uri_source.make (var27_xsl_uri.full_reference)
  356. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  357. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  358. l_transformer := l_transformer_factory.created_transformer
  359. assert ("transformer", l_transformer /= Void)
  360. check asserted_above: l_transformer /= Void then end
  361. create l_second_uri_source.make (var25_xml_uri.full_reference)
  362. create l_output
  363. l_output.set_output_to_string
  364. create l_result.make (l_output, "string:")
  365. l_transformer.transform (l_second_uri_source, l_result)
  366. assert ("Transform successful", not l_transformer.is_error)
  367. l_last_output := l_output.last_output
  368. assert ("set_output_to_string", l_last_output /= Void)
  369. check asserted_above: l_last_output /= Void then end
  370. assert ("Correct result", STRING_.same_string (l_last_output, expected_result_string_five))
  371. end
  372. test_required_tunnel_parameter_missing
  373. -- Test missing required tunnel parameter.
  374. local
  375. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  376. l_configuration: XM_XSLT_CONFIGURATION
  377. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  378. l_transformer: detachable XM_XSLT_TRANSFORMER
  379. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  380. l_output: XM_OUTPUT
  381. l_result: XM_XSLT_TRANSFORMATION_RESULT
  382. do
  383. conformance.set_basic_xslt_processor
  384. create l_configuration.make_with_defaults
  385. create l_error_listener.make (l_configuration.recovery_policy)
  386. l_configuration.set_error_listener (l_error_listener)
  387. l_configuration.set_line_numbering (True)
  388. create l_transformer_factory.make (l_configuration)
  389. create l_uri_source.make (var905err_xsl_uri.full_reference)
  390. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  391. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  392. l_transformer := l_transformer_factory.created_transformer
  393. assert ("transformer", l_transformer /= Void)
  394. check asserted_above: l_transformer /= Void then end
  395. create l_second_uri_source.make (var20_xml_uri.full_reference)
  396. create l_output
  397. l_output.set_output_to_string
  398. create l_result.make (l_output, "string:")
  399. l_transformer.transform (l_second_uri_source, l_result)
  400. assert ("Error", l_transformer.is_error)
  401. assert ("XTDE0700", l_error_listener.has (xtde0700))
  402. end
  403. test_type_error_on_tunnel_parameter
  404. -- Test tunnel parameter with wrong type.
  405. local
  406. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  407. l_configuration: XM_XSLT_CONFIGURATION
  408. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  409. l_transformer: detachable XM_XSLT_TRANSFORMER
  410. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  411. l_output: XM_OUTPUT
  412. l_result: XM_XSLT_TRANSFORMATION_RESULT
  413. do
  414. conformance.set_basic_xslt_processor
  415. create l_configuration.make_with_defaults
  416. create l_error_listener.make (l_configuration.recovery_policy)
  417. l_configuration.set_error_listener (l_error_listener)
  418. l_configuration.set_line_numbering (True)
  419. create l_transformer_factory.make (l_configuration)
  420. create l_uri_source.make (var906err_xsl_uri.full_reference)
  421. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  422. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  423. l_transformer := l_transformer_factory.created_transformer
  424. assert ("transformer", l_transformer /= Void)
  425. check asserted_above: l_transformer /= Void then end
  426. create l_second_uri_source.make (var20_xml_uri.full_reference)
  427. create l_output
  428. l_output.set_output_to_string
  429. create l_result.make (l_output, "string:")
  430. l_transformer.transform (l_second_uri_source, l_result)
  431. assert ("Error", l_transformer.is_error)
  432. assert ("XTTE0590", l_error_listener.has (xtte0590))
  433. end
  434. test_duplicate_parameter_names
  435. -- Test two parameters with same name.
  436. local
  437. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  438. l_configuration: XM_XSLT_CONFIGURATION
  439. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  440. l_uri_source: XM_XSLT_URI_SOURCE
  441. do
  442. conformance.set_basic_xslt_processor
  443. create l_configuration.make_with_defaults
  444. create l_error_listener.make (l_configuration.recovery_policy)
  445. l_configuration.set_error_listener (l_error_listener)
  446. l_configuration.set_line_numbering (True)
  447. create l_transformer_factory.make (l_configuration)
  448. create l_uri_source.make (var901err_xsl_uri.full_reference)
  449. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  450. assert ("XTSE0580", l_transformer_factory.was_error)
  451. end
  452. test_missing_required_global_parameter
  453. -- Test missing required global parameter.
  454. local
  455. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  456. l_configuration: XM_XSLT_CONFIGURATION
  457. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  458. l_transformer: detachable XM_XSLT_TRANSFORMER
  459. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  460. l_output: XM_OUTPUT
  461. l_result: XM_XSLT_TRANSFORMATION_RESULT
  462. do
  463. conformance.set_basic_xslt_processor
  464. create l_configuration.make_with_defaults
  465. create l_error_listener.make (l_configuration.recovery_policy)
  466. l_configuration.set_error_listener (l_error_listener)
  467. l_configuration.set_line_numbering (True)
  468. create l_transformer_factory.make (l_configuration)
  469. create l_uri_source.make (var902err_xsl_uri.full_reference)
  470. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  471. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  472. l_transformer := l_transformer_factory.created_transformer
  473. assert ("transformer", l_transformer /= Void)
  474. check asserted_above: l_transformer /= Void then end
  475. create l_second_uri_source.make (var25_xml_uri.full_reference)
  476. create l_output
  477. l_output.set_output_to_string
  478. create l_result.make (l_output, "string:")
  479. l_transformer.transform (l_second_uri_source, l_result)
  480. assert ("XTDE0050", l_transformer.is_error)
  481. assert ("XTDE0050a", l_error_listener.has (xtde0050))
  482. end
  483. test_variable_with_incorrect_supplied_type
  484. -- Test variable with wrong type for supplied data..
  485. local
  486. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  487. l_configuration: XM_XSLT_CONFIGURATION
  488. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  489. l_uri_source: XM_XSLT_URI_SOURCE
  490. do
  491. conformance.set_basic_xslt_processor
  492. create l_configuration.make_with_defaults
  493. create l_error_listener.make (l_configuration.recovery_policy)
  494. l_configuration.set_error_listener (l_error_listener)
  495. l_configuration.set_line_numbering (True)
  496. create l_transformer_factory.make (l_configuration)
  497. create l_uri_source.make (var903err_xsl_uri.full_reference)
  498. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  499. assert ("XTTE0570", l_transformer_factory.was_error)
  500. end
  501. test_type_error_on_local_parameter
  502. -- Test missing required global parameter.
  503. local
  504. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  505. l_configuration: XM_XSLT_CONFIGURATION
  506. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  507. l_transformer: detachable XM_XSLT_TRANSFORMER
  508. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  509. l_output: XM_OUTPUT
  510. l_result: XM_XSLT_TRANSFORMATION_RESULT
  511. do
  512. conformance.set_basic_xslt_processor
  513. create l_configuration.make_with_defaults
  514. create l_error_listener.make (l_configuration.recovery_policy)
  515. l_configuration.set_error_listener (l_error_listener)
  516. l_configuration.set_line_numbering (True)
  517. create l_transformer_factory.make (l_configuration)
  518. create l_uri_source.make (var904err_xsl_uri.full_reference)
  519. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  520. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  521. l_transformer := l_transformer_factory.created_transformer
  522. assert ("transformer", l_transformer /= Void)
  523. check asserted_above: l_transformer /= Void then end
  524. create l_second_uri_source.make (var25_xml_uri.full_reference)
  525. create l_output
  526. l_output.set_output_to_string
  527. create l_result.make (l_output, "string:")
  528. l_transformer.transform (l_second_uri_source, l_result)
  529. assert ("Error", l_transformer.is_error)
  530. assert ("XTTE0590", l_error_listener.has (xtte0590))
  531. end
  532. test_variable_with_missing_typed_value
  533. -- Test missing value for integer-valued varaible.
  534. local
  535. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  536. l_configuration: XM_XSLT_CONFIGURATION
  537. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  538. l_transformer: detachable XM_XSLT_TRANSFORMER
  539. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  540. l_output: XM_OUTPUT
  541. l_result: XM_XSLT_TRANSFORMATION_RESULT
  542. do
  543. conformance.set_basic_xslt_processor
  544. create l_configuration.make_with_defaults
  545. create l_error_listener.make (l_configuration.recovery_policy)
  546. l_configuration.set_error_listener (l_error_listener)
  547. l_configuration.set_line_numbering (True)
  548. create l_transformer_factory.make (l_configuration)
  549. create l_uri_source.make (var907err_xsl_uri.full_reference)
  550. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  551. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  552. l_transformer := l_transformer_factory.created_transformer
  553. assert ("transformer", l_transformer /= Void)
  554. check asserted_above: l_transformer /= Void then end
  555. create l_second_uri_source.make (var25_xml_uri.full_reference)
  556. create l_output
  557. l_output.set_output_to_string
  558. create l_result.make (l_output, "string:")
  559. l_transformer.transform (l_second_uri_source, l_result)
  560. assert ("Error", l_transformer.is_error)
  561. assert ("FORG0001", l_error_listener.has (forg0001))
  562. end
  563. test_variable_with_incorrect_complex_type
  564. -- Test variable with wrong (element) type for supplied data..
  565. local
  566. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  567. l_configuration: XM_XSLT_CONFIGURATION
  568. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  569. l_uri_source: XM_XSLT_URI_SOURCE
  570. do
  571. conformance.set_basic_xslt_processor
  572. create l_configuration.make_with_defaults
  573. create l_error_listener.make (l_configuration.recovery_policy)
  574. l_configuration.set_error_listener (l_error_listener)
  575. l_configuration.set_line_numbering (True)
  576. create l_transformer_factory.make (l_configuration)
  577. create l_uri_source.make (var908err_xsl_uri.full_reference)
  578. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  579. assert ("XTTE0570", l_transformer_factory.was_error)
  580. end
  581. test_variable_with_incorrect_cardinality
  582. -- Test variable with incorrect cardinality.
  583. local
  584. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  585. l_configuration: XM_XSLT_CONFIGURATION
  586. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  587. l_transformer: detachable XM_XSLT_TRANSFORMER
  588. l_uri_source, l_second_uri_source: XM_XSLT_URI_SOURCE
  589. l_output: XM_OUTPUT
  590. l_result: XM_XSLT_TRANSFORMATION_RESULT
  591. do
  592. conformance.set_basic_xslt_processor
  593. create l_configuration.make_with_defaults
  594. create l_error_listener.make (l_configuration.recovery_policy)
  595. l_configuration.set_error_listener (l_error_listener)
  596. l_configuration.set_line_numbering (True)
  597. create l_transformer_factory.make (l_configuration)
  598. create l_uri_source.make (var909err_xsl_uri.full_reference)
  599. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  600. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  601. l_transformer := l_transformer_factory.created_transformer
  602. assert ("transformer", l_transformer /= Void)
  603. check asserted_above: l_transformer /= Void then end
  604. create l_second_uri_source.make (var25_xml_uri.full_reference)
  605. create l_output
  606. l_output.set_output_to_string
  607. create l_result.make (l_output, "string:")
  608. l_transformer.transform (l_second_uri_source, l_result)
  609. assert ("Error", l_transformer.is_error)
  610. assert ("XTTE0570", l_error_listener.has (xtte0570))
  611. end
  612. feature -- Results
  613. expected_result_string_one: STRING = "<?xml version=%"1.0%" encoding=%"UTF-8%"?>%N%T<b><d>17</d></b>%N"
  614. -- Expected result for `test_tunnel_parameters'
  615. expected_result_string_two: STRING = "<?xml version=%"1.0%" encoding=%"UTF-8%"?><out>%N%T<b><d t1=%"17%" t2=%"28%" t3=%"38%"/></b><old>18</old>%N</out>"
  616. -- Expected result for `test_override_tunnel_parameter'
  617. expected_result_string_three: STRING = "<?xml version=%"1.0%" encoding=%"UTF-8%"?><out>%N%T<b t1=%"mushroom%"><d t1=%"17%" t2=%"28%" t3=%"38%"/></b><old>18</old>%N</out>"
  618. -- Expected result for `test_normal_versus_tunnel_parameters'
  619. expected_result_string_four: STRING = "<?xml version=%"1.0%" encoding=%"UTF-8%"?>%N<a>x = abc</a>"
  620. -- Expected result for `test_tunnel_parameters_with_variable_contents'
  621. expected_result_string_five: STRING = "<?xml version=%"1.0%" encoding=%"UTF-8%"?>%N<a>abc</a>"
  622. -- Expected result for `test_supplied_tunnel_parameter'
  623. expected_result_string_six: STRING = "<?xml version=%"1.0%" encoding=%"UTF-8%"?><out count=%"3%"/>"
  624. -- Expected result for `test_as_attribute_on_with_param'
  625. expected_result_string_seven: STRING = "<?xml version=%"1.0%" encoding=%"UTF-8%"?><out test=%"true%"/>"
  626. -- Expected result for `test_type_conversion_on_apply'
  627. expected_result_string_eight: STRING = "<?xml version=%"1.0%" encoding=%"UTF-8%"?><out xmlns:xs=%"http://www.w3.org/2001/XMLSchema%" x=%"55%" z=%"22%" is-integer=%"true%"/>"
  628. -- Expected result for `test_range_variable_in_global_variable'
  629. feature {NONE} -- Implementation
  630. data_dirname: STRING
  631. -- Name of directory containing data files
  632. once
  633. Result := file_system.nested_pathname ("${GOBO}", <<"library", "xslt", "test", "unit", "data">>)
  634. Result := Execution_environment.interpreted_string (Result)
  635. ensure
  636. data_dirname_not_void: Result /= Void
  637. data_dirname_not_empty: not Result.is_empty
  638. end
  639. dummy_uri: UT_URI
  640. -- Dummy URI
  641. once
  642. create Result.make ("dummy:")
  643. ensure
  644. dummy_uri_is_absolute: Result /= Void and then Result.is_absolute
  645. end
  646. var15_xsl_uri: UT_URI
  647. -- URI of file 'var15.xsl'
  648. local
  649. l_path: STRING
  650. once
  651. l_path := file_system.pathname (data_dirname, "var15.xsl")
  652. Result := File_uri.filename_to_uri (l_path)
  653. ensure
  654. var15_xsl_uri_not_void: Result /= Void
  655. end
  656. var25_xml_uri: UT_URI
  657. -- URI of file 'var25.xml'
  658. local
  659. l_path: STRING
  660. once
  661. l_path := file_system.pathname (data_dirname, "var25.xml")
  662. Result := File_uri.filename_to_uri (l_path)
  663. ensure
  664. var25_xml_uri_not_void: Result /= Void
  665. end
  666. var16_xsl_uri: UT_URI
  667. -- URI of file 'var16.xsl'
  668. local
  669. l_path: STRING
  670. once
  671. l_path := file_system.pathname (data_dirname, "var16.xsl")
  672. Result := File_uri.filename_to_uri (l_path)
  673. ensure
  674. var16_xsl_uri_not_void: Result /= Void
  675. end
  676. var17_xsl_uri: UT_URI
  677. -- URI of file 'var17.xsl'
  678. local
  679. l_path: STRING
  680. once
  681. l_path := file_system.pathname (data_dirname, "var17.xsl")
  682. Result := File_uri.filename_to_uri (l_path)
  683. ensure
  684. var17_xsl_uri_not_void: Result /= Void
  685. end
  686. var20_xsl_uri: UT_URI
  687. -- URI of file 'var20.xsl'
  688. local
  689. l_path: STRING
  690. once
  691. l_path := file_system.pathname (data_dirname, "var20.xsl")
  692. Result := File_uri.filename_to_uri (l_path)
  693. ensure
  694. var20_xsl_uri_not_void: Result /= Void
  695. end
  696. var20_xml_uri: UT_URI
  697. -- URI of file 'var20.xml'
  698. local
  699. l_path: STRING
  700. once
  701. l_path := file_system.pathname (data_dirname, "var20.xml")
  702. Result := File_uri.filename_to_uri (l_path)
  703. ensure
  704. var20_xml_uri_not_void: Result /= Void
  705. end
  706. var21_xsl_uri: UT_URI
  707. -- URI of file 'var21.xsl'
  708. local
  709. l_path: STRING
  710. once
  711. l_path := file_system.pathname (data_dirname, "var21.xsl")
  712. Result := File_uri.filename_to_uri (l_path)
  713. ensure
  714. var21_xsl_uri_not_void: Result /= Void
  715. end
  716. var22_xsl_uri: UT_URI
  717. -- URI of file 'var22.xsl'
  718. local
  719. l_path: STRING
  720. once
  721. l_path := file_system.pathname (data_dirname, "var22.xsl")
  722. Result := File_uri.filename_to_uri (l_path)
  723. ensure
  724. var22_xsl_uri_not_void: Result /= Void
  725. end
  726. var23_xsl_uri: UT_URI
  727. -- URI of file 'var23.xsl'
  728. local
  729. l_path: STRING
  730. once
  731. l_path := file_system.pathname (data_dirname, "var23.xsl")
  732. Result := File_uri.filename_to_uri (l_path)
  733. ensure
  734. var23_xsl_uri_not_void: Result /= Void
  735. end
  736. var25_xsl_uri: UT_URI
  737. -- URI of file 'var25.xsl'
  738. local
  739. l_path: STRING
  740. once
  741. l_path := file_system.pathname (data_dirname, "var25.xsl")
  742. Result := File_uri.filename_to_uri (l_path)
  743. ensure
  744. var25_xsl_uri_not_void: Result /= Void
  745. end
  746. var26_xsl_uri: UT_URI
  747. -- URI of file 'var26.xsl'
  748. local
  749. l_path: STRING
  750. once
  751. l_path := file_system.pathname (data_dirname, "var26.xsl")
  752. Result := File_uri.filename_to_uri (l_path)
  753. ensure
  754. var26_xsl_uri_not_void: Result /= Void
  755. end
  756. var27_xsl_uri: UT_URI
  757. -- URI of file 'var27.xsl'
  758. local
  759. l_path: STRING
  760. once
  761. l_path := file_system.pathname (data_dirname, "var27.xsl")
  762. Result := File_uri.filename_to_uri (l_path)
  763. ensure
  764. var27_xsl_uri_not_void: Result /= Void
  765. end
  766. var905err_xsl_uri: UT_URI
  767. -- URI of file 'var905err.xsl'
  768. local
  769. l_path: STRING
  770. once
  771. l_path := file_system.pathname (data_dirname, "var905err.xsl")
  772. Result := File_uri.filename_to_uri (l_path)
  773. ensure
  774. var905err_xsl_uri_not_void: Result /= Void
  775. end
  776. var906err_xsl_uri: UT_URI
  777. -- URI of file 'var906err.xsl'
  778. local
  779. l_path: STRING
  780. once
  781. l_path := file_system.pathname (data_dirname, "var906err.xsl")
  782. Result := File_uri.filename_to_uri (l_path)
  783. ensure
  784. var906err_xsl_uri_not_void: Result /= Void
  785. end
  786. var901err_xsl_uri: UT_URI
  787. -- URI of file 'var901err.xsl'
  788. local
  789. l_path: STRING
  790. once
  791. l_path := file_system.pathname (data_dirname, "var901err.xsl")
  792. Result := File_uri.filename_to_uri (l_path)
  793. ensure
  794. var901err_xsl_uri_not_void: Result /= Void
  795. end
  796. var902err_xsl_uri: UT_URI
  797. -- URI of file 'var902err.xsl'
  798. local
  799. l_path: STRING
  800. once
  801. l_path := file_system.pathname (data_dirname, "var902err.xsl")
  802. Result := File_uri.filename_to_uri (l_path)
  803. ensure
  804. var902err_xsl_uri_not_void: Result /= Void
  805. end
  806. var903err_xsl_uri: UT_URI
  807. -- URI of file 'var903err.xsl'
  808. local
  809. l_path: STRING
  810. once
  811. l_path := file_system.pathname (data_dirname, "var903err.xsl")
  812. Result := File_uri.filename_to_uri (l_path)
  813. ensure
  814. var903err_xsl_uri_not_void: Result /= Void
  815. end
  816. var904err_xsl_uri: UT_URI
  817. -- URI of file 'var904err.xsl'
  818. local
  819. l_path: STRING
  820. once
  821. l_path := file_system.pathname (data_dirname, "var904err.xsl")
  822. Result := File_uri.filename_to_uri (l_path)
  823. ensure
  824. var904err_xsl_uri_not_void: Result /= Void
  825. end
  826. var907err_xsl_uri: UT_URI
  827. -- URI of file 'var907err.xsl'
  828. local
  829. l_path: STRING
  830. once
  831. l_path := file_system.pathname (data_dirname, "var907err.xsl")
  832. Result := File_uri.filename_to_uri (l_path)
  833. ensure
  834. var907err_xsl_uri_not_void: Result /= Void
  835. end
  836. var908err_xsl_uri: UT_URI
  837. -- URI of file 'var908err.xsl'
  838. local
  839. l_path: STRING
  840. once
  841. l_path := file_system.pathname (data_dirname, "var908err.xsl")
  842. Result := File_uri.filename_to_uri (l_path)
  843. ensure
  844. var908err_xsl_uri_not_void: Result /= Void
  845. end
  846. var909err_xsl_uri: UT_URI
  847. -- URI of file 'var909err.xsl'
  848. local
  849. l_path: STRING
  850. once
  851. l_path := file_system.pathname (data_dirname, "var909err.xsl")
  852. Result := File_uri.filename_to_uri (l_path)
  853. ensure
  854. var909err_xsl_uri_not_void: Result /= Void
  855. end
  856. xtde0700: STRING
  857. -- Error XTDE0700
  858. once
  859. Result := Xpath_errors_uri + "#" + "XTDE0700"
  860. ensure
  861. xtde0700_not_void: Result /= Void
  862. end
  863. xtte0590: STRING
  864. -- Error XTTE0590
  865. once
  866. Result := Xpath_errors_uri + "#" + "XTTE0590"
  867. ensure
  868. xtte0590_not_void: Result /= Void
  869. end
  870. xtde0050: STRING
  871. -- Error XTDE0050
  872. once
  873. Result := Xpath_errors_uri + "#" + "XTDE0050"
  874. ensure
  875. xtde0050_not_void: Result /= Void
  876. end
  877. forg0001: STRING
  878. -- Error FORG0001
  879. once
  880. Result := Xpath_errors_uri + "#" + "FORG0001"
  881. ensure
  882. forg0001_not_void: Result /= Void
  883. end
  884. xtte0570: STRING
  885. -- Error XTTE0570
  886. once
  887. Result := Xpath_errors_uri + "#" + "XTTE0570"
  888. ensure
  889. xtte0570_not_void: Result /= Void
  890. end
  891. end