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

/library/xslt/test/unit/xm_xslt_test_formatting.e

http://github.com/gobo-eiffel/gobo
Specman e | 695 lines | 619 code | 48 blank | 28 comment | 0 complexity | 3f8b086686b79284780f6a67a766075f MD5 | raw file
  1. note
  2. description:
  3. "Test format-date(), format-time() and format-dateTime()"
  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_FORMATTING
  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. create
  18. make_default
  19. feature -- Test
  20. test_format_date_one
  21. -- Test format-date(xs:date ('2002-12-31'), '[Y0001]-[M01]-[D01]').
  22. local
  23. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  24. l_configuration: XM_XSLT_CONFIGURATION
  25. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  26. l_transformer: detachable XM_XSLT_TRANSFORMER
  27. l_uri_source: XM_XSLT_URI_SOURCE
  28. l_output: XM_OUTPUT
  29. l_result: XM_XSLT_TRANSFORMATION_RESULT
  30. l_last_output: detachable STRING
  31. do
  32. conformance.set_basic_xslt_processor
  33. create l_configuration.make_with_defaults
  34. create l_error_listener.make (l_configuration.recovery_policy)
  35. l_configuration.set_error_listener (l_error_listener)
  36. l_configuration.set_line_numbering (True)
  37. l_configuration.use_tiny_tree_model (True)
  38. create l_transformer_factory.make (l_configuration)
  39. create l_uri_source.make (format1_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. l_transformer.set_initial_template ("first")
  46. create l_output
  47. l_output.set_output_to_string
  48. create l_result.make (l_output, "string:")
  49. l_transformer.transform (Void, l_result)
  50. assert ("Transform successful", not l_transformer.is_error)
  51. l_last_output := l_output.last_output
  52. assert ("set_output_to_string", l_last_output /= Void)
  53. check asserted_above: l_last_output /= Void then end
  54. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_date_format_one))
  55. end
  56. test_format_date_two
  57. -- Test format-date(xs:date ('2002-12-31'), '[M]-[D]-[Y]').
  58. local
  59. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  60. l_configuration: XM_XSLT_CONFIGURATION
  61. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  62. l_transformer: detachable XM_XSLT_TRANSFORMER
  63. l_uri_source: XM_XSLT_URI_SOURCE
  64. l_output: XM_OUTPUT
  65. l_result: XM_XSLT_TRANSFORMATION_RESULT
  66. l_last_output: detachable STRING
  67. do
  68. conformance.set_basic_xslt_processor
  69. create l_configuration.make_with_defaults
  70. create l_error_listener.make (l_configuration.recovery_policy)
  71. l_configuration.set_error_listener (l_error_listener)
  72. l_configuration.set_line_numbering (True)
  73. l_configuration.use_tiny_tree_model (True)
  74. create l_transformer_factory.make (l_configuration)
  75. create l_uri_source.make (format2_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. l_transformer.set_initial_template ("first")
  82. create l_output
  83. l_output.set_output_to_string
  84. create l_result.make (l_output, "string:")
  85. l_transformer.transform (Void, 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.out, expected_result_date_format_two))
  91. end
  92. test_format_date_three
  93. -- Test format-date(xs:date ('2002-12-31'), '[D]-[M]-[Y]').
  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: 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. l_configuration.use_tiny_tree_model (True)
  110. create l_transformer_factory.make (l_configuration)
  111. create l_uri_source.make (format3_xsl_uri.full_reference)
  112. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  113. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  114. l_transformer := l_transformer_factory.created_transformer
  115. assert ("transformer", l_transformer /= Void)
  116. check asserted_above: l_transformer /= Void then end
  117. l_transformer.set_initial_template ("first")
  118. create l_output
  119. l_output.set_output_to_string
  120. create l_result.make (l_output, "string:")
  121. l_transformer.transform (Void, l_result)
  122. assert ("Transform successful", not l_transformer.is_error)
  123. l_last_output := l_output.last_output
  124. assert ("set_output_to_string", l_last_output /= Void)
  125. check asserted_above: l_last_output /= Void then end
  126. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_date_format_three))
  127. end
  128. test_format_date_four
  129. -- Test format-date(xs:date ('2002-12-31'), '[D1] [MI] [Y]').
  130. local
  131. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  132. l_configuration: XM_XSLT_CONFIGURATION
  133. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  134. l_transformer: detachable XM_XSLT_TRANSFORMER
  135. l_uri_source: XM_XSLT_URI_SOURCE
  136. l_output: XM_OUTPUT
  137. l_result: XM_XSLT_TRANSFORMATION_RESULT
  138. l_last_output: detachable STRING
  139. do
  140. conformance.set_basic_xslt_processor
  141. create l_configuration.make_with_defaults
  142. create l_error_listener.make (l_configuration.recovery_policy)
  143. l_configuration.set_error_listener (l_error_listener)
  144. l_configuration.set_line_numbering (True)
  145. l_configuration.use_tiny_tree_model (True)
  146. create l_transformer_factory.make (l_configuration)
  147. create l_uri_source.make (format4_xsl_uri.full_reference)
  148. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  149. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  150. l_transformer := l_transformer_factory.created_transformer
  151. assert ("transformer", l_transformer /= Void)
  152. check asserted_above: l_transformer /= Void then end
  153. l_transformer.set_initial_template ("first")
  154. create l_output
  155. l_output.set_output_to_string
  156. create l_result.make (l_output, "string:")
  157. l_transformer.transform (Void, l_result)
  158. assert ("Transform successful", not l_transformer.is_error)l_last_output := l_output.last_output
  159. assert ("set_output_to_string", l_last_output /= Void)
  160. check asserted_above: l_last_output /= Void then end
  161. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_date_format_four))
  162. end
  163. test_format_date_five
  164. -- Test format-date(xs:date ('2002-12-31'), '[D1o] [MNn], [Y]', 'en', (), ()).
  165. local
  166. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  167. l_configuration: XM_XSLT_CONFIGURATION
  168. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  169. l_transformer: detachable XM_XSLT_TRANSFORMER
  170. l_uri_source: XM_XSLT_URI_SOURCE
  171. l_output: XM_OUTPUT
  172. l_result: XM_XSLT_TRANSFORMATION_RESULT
  173. l_last_output: detachable STRING
  174. do
  175. conformance.set_basic_xslt_processor
  176. create l_configuration.make_with_defaults
  177. create l_error_listener.make (l_configuration.recovery_policy)
  178. l_configuration.set_error_listener (l_error_listener)
  179. l_configuration.set_line_numbering (True)
  180. l_configuration.use_tiny_tree_model (True)
  181. create l_transformer_factory.make (l_configuration)
  182. create l_uri_source.make (format5_xsl_uri.full_reference)
  183. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  184. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  185. l_transformer := l_transformer_factory.created_transformer
  186. assert ("transformer", l_transformer /= Void)
  187. check asserted_above: l_transformer /= Void then end
  188. l_transformer.set_initial_template ("first")
  189. create l_output
  190. l_output.set_output_to_string
  191. create l_result.make (l_output, "string:")
  192. l_transformer.transform (Void, l_result)
  193. assert ("Transform successful", not l_transformer.is_error)
  194. l_last_output := l_output.last_output
  195. assert ("set_output_to_string", l_last_output /= Void)
  196. check asserted_above: l_last_output /= Void then end
  197. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_date_format_five))
  198. end
  199. test_format_date_six
  200. -- Test format-date(xs:date ('2002-12-31'), '[[[Y0001]-[M01]-[D01]]]', 'en', 'AD', 'GB').
  201. local
  202. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  203. l_configuration: XM_XSLT_CONFIGURATION
  204. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  205. l_transformer: detachable XM_XSLT_TRANSFORMER
  206. l_uri_source: XM_XSLT_URI_SOURCE
  207. l_output: XM_OUTPUT
  208. l_result: XM_XSLT_TRANSFORMATION_RESULT
  209. l_last_output: detachable STRING
  210. do
  211. conformance.set_basic_xslt_processor
  212. create l_configuration.make_with_defaults
  213. create l_error_listener.make (l_configuration.recovery_policy)
  214. l_configuration.set_error_listener (l_error_listener)
  215. l_configuration.set_line_numbering (True)
  216. l_configuration.use_tiny_tree_model (True)
  217. create l_transformer_factory.make (l_configuration)
  218. create l_uri_source.make (format6_xsl_uri.full_reference)
  219. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  220. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  221. l_transformer := l_transformer_factory.created_transformer
  222. assert ("transformer", l_transformer /= Void)
  223. check asserted_above: l_transformer /= Void then end
  224. l_transformer.set_initial_template ("first")
  225. create l_output
  226. l_output.set_output_to_string
  227. create l_result.make (l_output, "string:")
  228. l_transformer.transform (Void, l_result)
  229. assert ("Transform successful", not l_transformer.is_error)
  230. l_last_output := l_output.last_output
  231. assert ("set_output_to_string", l_last_output /= Void)
  232. check asserted_above: l_last_output /= Void then end
  233. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_date_format_six))
  234. end
  235. test_format_date_seven
  236. -- Test format-date(xs:date ('2002-12-31'), '[YWw]', 'en', 'CE', ()).
  237. local
  238. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  239. l_configuration: XM_XSLT_CONFIGURATION
  240. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  241. l_transformer: detachable XM_XSLT_TRANSFORMER
  242. l_uri_source: XM_XSLT_URI_SOURCE
  243. l_output: XM_OUTPUT
  244. l_result: XM_XSLT_TRANSFORMATION_RESULT
  245. l_last_output: detachable STRING
  246. do
  247. conformance.set_basic_xslt_processor
  248. create l_configuration.make_with_defaults
  249. create l_error_listener.make (l_configuration.recovery_policy)
  250. l_configuration.set_error_listener (l_error_listener)
  251. l_configuration.set_line_numbering (True)
  252. l_configuration.use_tiny_tree_model (True)
  253. create l_transformer_factory.make (l_configuration)
  254. create l_uri_source.make (format7_xsl_uri.full_reference)
  255. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  256. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  257. l_transformer := l_transformer_factory.created_transformer
  258. assert ("transformer", l_transformer /= Void)
  259. check asserted_above: l_transformer /= Void then end
  260. l_transformer.set_initial_template ("first")
  261. create l_output
  262. l_output.set_output_to_string
  263. create l_result.make (l_output, "string:")
  264. l_transformer.transform (Void, l_result)
  265. assert ("Transform successful", not l_transformer.is_error)l_last_output := l_output.last_output
  266. assert ("set_output_to_string", l_last_output /= Void)
  267. check asserted_above: l_last_output /= Void then end
  268. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_date_format_seven))
  269. end
  270. test_format_time_one
  271. -- Test format-time(xs:time ('15:58:45.762'), '[h]:[m01] [PN, *-2]', 'en', 'CE', ()).
  272. local
  273. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  274. l_configuration: XM_XSLT_CONFIGURATION
  275. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  276. l_transformer: detachable XM_XSLT_TRANSFORMER
  277. l_uri_source: XM_XSLT_URI_SOURCE
  278. l_output: XM_OUTPUT
  279. l_result: XM_XSLT_TRANSFORMATION_RESULT
  280. l_last_output: detachable STRING
  281. do
  282. conformance.set_basic_xslt_processor
  283. create l_configuration.make_with_defaults
  284. create l_error_listener.make (l_configuration.recovery_policy)
  285. l_configuration.set_error_listener (l_error_listener)
  286. l_configuration.set_line_numbering (True)
  287. l_configuration.use_tiny_tree_model (True)
  288. create l_transformer_factory.make (l_configuration)
  289. create l_uri_source.make (format_time1_xsl_uri.full_reference)
  290. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  291. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  292. l_transformer := l_transformer_factory.created_transformer
  293. assert ("transformer", l_transformer /= Void)
  294. check asserted_above: l_transformer /= Void then end
  295. l_transformer.set_initial_template ("first")
  296. create l_output
  297. l_output.set_output_to_string
  298. create l_result.make (l_output, "string:")
  299. l_transformer.transform (Void, l_result)
  300. assert ("Transform successful", not l_transformer.is_error)
  301. l_last_output := l_output.last_output
  302. assert ("set_output_to_string", l_last_output /= Void)
  303. check asserted_above: l_last_output /= Void then end
  304. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_time_format_one))
  305. end
  306. test_format_time_two
  307. -- Test format-time(xs:time ('15:58:45.762'), '[h]:[m01]:[s01] [Pn, 1-2]', 'en', (), ()).
  308. local
  309. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  310. l_configuration: XM_XSLT_CONFIGURATION
  311. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  312. l_transformer: detachable XM_XSLT_TRANSFORMER
  313. l_uri_source: XM_XSLT_URI_SOURCE
  314. l_output: XM_OUTPUT
  315. l_result: XM_XSLT_TRANSFORMATION_RESULT
  316. l_last_output: detachable STRING
  317. do
  318. conformance.set_basic_xslt_processor
  319. create l_configuration.make_with_defaults
  320. create l_error_listener.make (l_configuration.recovery_policy)
  321. l_configuration.set_error_listener (l_error_listener)
  322. l_configuration.set_line_numbering (True)
  323. l_configuration.use_tiny_tree_model (True)
  324. create l_transformer_factory.make (l_configuration)
  325. create l_uri_source.make (format_time2_xsl_uri.full_reference)
  326. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  327. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  328. l_transformer := l_transformer_factory.created_transformer
  329. assert ("transformer", l_transformer /= Void)
  330. check asserted_above: l_transformer /= Void then end
  331. l_transformer.set_initial_template ("first")
  332. create l_output
  333. l_output.set_output_to_string
  334. create l_result.make (l_output, "string:")
  335. l_transformer.transform (Void, l_result)
  336. assert ("Transform successful", not l_transformer.is_error)
  337. l_last_output := l_output.last_output
  338. assert ("set_output_to_string", l_last_output /= Void)
  339. check asserted_above: l_last_output /= Void then end
  340. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_time_format_two))
  341. end
  342. test_format_time_three
  343. -- Test format-time(xs:time ('15:58:45.762'), '[H01]:[m01]:[s01].[f001]', 'en', (), ()).
  344. local
  345. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  346. l_configuration: XM_XSLT_CONFIGURATION
  347. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  348. l_transformer: detachable XM_XSLT_TRANSFORMER
  349. l_uri_source: XM_XSLT_URI_SOURCE
  350. l_output: XM_OUTPUT
  351. l_result: XM_XSLT_TRANSFORMATION_RESULT
  352. l_last_output: detachable STRING
  353. do
  354. conformance.set_basic_xslt_processor
  355. create l_configuration.make_with_defaults
  356. create l_error_listener.make (l_configuration.recovery_policy)
  357. l_configuration.set_error_listener (l_error_listener)
  358. l_configuration.set_line_numbering (True)
  359. l_configuration.use_tiny_tree_model (True)
  360. create l_transformer_factory.make (l_configuration)
  361. create l_uri_source.make (format_time3_xsl_uri.full_reference)
  362. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  363. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  364. l_transformer := l_transformer_factory.created_transformer
  365. assert ("transformer", l_transformer /= Void)
  366. check asserted_above: l_transformer /= Void then end
  367. l_transformer.set_initial_template ("first")
  368. create l_output
  369. l_output.set_output_to_string
  370. create l_result.make (l_output, "string:")
  371. l_transformer.transform (Void, l_result)
  372. assert ("Transform successful", not l_transformer.is_error)
  373. l_last_output := l_output.last_output
  374. assert ("set_output_to_string", l_last_output /= Void)
  375. check asserted_above: l_last_output /= Void then end
  376. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_time_format_three))
  377. end
  378. test_format_time_four
  379. -- Test format-time(xs:time ('15:58:45.762+02:00'), '[H01]:[m01]:[s01] [z]', 'en', (), ()).
  380. local
  381. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  382. l_configuration: XM_XSLT_CONFIGURATION
  383. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  384. l_transformer: detachable XM_XSLT_TRANSFORMER
  385. l_uri_source: XM_XSLT_URI_SOURCE
  386. l_output: XM_OUTPUT
  387. l_result: XM_XSLT_TRANSFORMATION_RESULT
  388. l_last_output: detachable STRING
  389. do
  390. conformance.set_basic_xslt_processor
  391. create l_configuration.make_with_defaults
  392. create l_error_listener.make (l_configuration.recovery_policy)
  393. l_configuration.set_error_listener (l_error_listener)
  394. l_configuration.set_line_numbering (True)
  395. l_configuration.use_tiny_tree_model (True)
  396. create l_transformer_factory.make (l_configuration)
  397. create l_uri_source.make (format_time4_xsl_uri.full_reference)
  398. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  399. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  400. l_transformer := l_transformer_factory.created_transformer
  401. assert ("transformer", l_transformer /= Void)
  402. check asserted_above: l_transformer /= Void then end
  403. l_transformer.set_initial_template ("first")
  404. create l_output
  405. l_output.set_output_to_string
  406. create l_result.make (l_output, "string:")
  407. l_transformer.transform (Void, l_result)
  408. assert ("Transform successful", not l_transformer.is_error)
  409. l_last_output := l_output.last_output
  410. assert ("set_output_to_string", l_last_output /= Void)
  411. check asserted_above: l_last_output /= Void then end
  412. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_time_format_four))
  413. end
  414. test_format_date_time_one
  415. -- Test format-dateTime(xs:dateTime ('2002-12-31T15:58:45.762+02:00'), '[h].[m01][Pn] on [FNn], [D1o] [MNn]').
  416. local
  417. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  418. l_configuration: XM_XSLT_CONFIGURATION
  419. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  420. l_transformer: detachable XM_XSLT_TRANSFORMER
  421. l_uri_source: XM_XSLT_URI_SOURCE
  422. l_output: XM_OUTPUT
  423. l_result: XM_XSLT_TRANSFORMATION_RESULT
  424. l_last_output: detachable STRING
  425. do
  426. conformance.set_basic_xslt_processor
  427. create l_configuration.make_with_defaults
  428. create l_error_listener.make (l_configuration.recovery_policy)
  429. l_configuration.set_error_listener (l_error_listener)
  430. l_configuration.set_line_numbering (True)
  431. l_configuration.use_tiny_tree_model (True)
  432. create l_transformer_factory.make (l_configuration)
  433. create l_uri_source.make (format_date_time1_xsl_uri.full_reference)
  434. l_transformer_factory.create_new_transformer (l_uri_source, dummy_uri)
  435. assert ("Stylesheet compiled without errors", not l_transformer_factory.was_error)
  436. l_transformer := l_transformer_factory.created_transformer
  437. assert ("transformer", l_transformer /= Void)
  438. check asserted_above: l_transformer /= Void then end
  439. l_transformer.set_initial_template ("first")
  440. create l_output
  441. l_output.set_output_to_string
  442. create l_result.make (l_output, "string:")
  443. l_transformer.transform (Void, l_result)
  444. assert ("Transform successful", not l_transformer.is_error)
  445. l_last_output := l_output.last_output
  446. assert ("set_output_to_string", l_last_output /= Void)
  447. check asserted_above: l_last_output /= Void then end
  448. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_date_time_format_one))
  449. end
  450. test_format_date_time_two
  451. -- Test format-dateTime(xs:dateTime ('2002-12-31T15:58:45.762+02:00'), '[M01]/[D01]/[Y0001] at [H01]:[m01]:[s01]').
  452. local
  453. l_transformer_factory: XM_XSLT_TRANSFORMER_FACTORY
  454. l_configuration: XM_XSLT_CONFIGURATION
  455. l_error_listener: XM_XSLT_TESTING_ERROR_LISTENER
  456. l_transformer: detachable XM_XSLT_TRANSFORMER
  457. l_uri_source: XM_XSLT_URI_SOURCE
  458. l_output: XM_OUTPUT
  459. l_result: XM_XSLT_TRANSFORMATION_RESULT
  460. l_last_output: detachable STRING
  461. do
  462. conformance.set_basic_xslt_processor
  463. create l_configuration.make_with_defaults
  464. create l_error_listener.make (l_configuration.recovery_policy)
  465. l_configuration.set_error_listener (l_error_listener)
  466. l_configuration.set_line_numbering (True)
  467. l_configuration.use_tiny_tree_model (True)
  468. create l_transformer_factory.make (l_configuration)
  469. create l_uri_source.make (format_date_time2_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. l_transformer.set_initial_template ("first")
  476. create l_output
  477. l_output.set_output_to_string
  478. create l_result.make (l_output, "string:")
  479. l_transformer.transform (Void, l_result)
  480. assert ("Transform successful", not l_transformer.is_error)
  481. l_last_output := l_output.last_output
  482. assert ("set_output_to_string", l_last_output /= Void)
  483. check asserted_above: l_last_output /= Void then end
  484. assert ("Correct result", STRING_.same_string (l_last_output.out, expected_result_date_time_format_two))
  485. end
  486. feature -- Result
  487. expected_result_date_format_one: STRING = "2002-12-31"
  488. expected_result_date_format_two: STRING = "12-31-2002"
  489. expected_result_date_format_three: STRING = "31-12-2002"
  490. expected_result_date_format_four: STRING = "31 XII 2002"
  491. expected_result_date_format_five: STRING = "31st December, 2002"
  492. expected_result_date_format_six: STRING = "[2002-12-31]"
  493. expected_result_date_format_seven: STRING = "Two Thousand and Two"
  494. expected_result_time_format_one: STRING = "3:58 PM"
  495. expected_result_time_format_two: STRING = "3:58:45 pm"
  496. expected_result_time_format_three: STRING = "15:58:45.762"
  497. expected_result_time_format_four: STRING = "15:58:45 GMT+02:00"
  498. expected_result_date_time_format_one: STRING = "3.58p.m. on Tuesday, 31st December"
  499. expected_result_date_time_format_two: STRING = "12/31/2002 at 15:58:45"
  500. feature {NONE} -- Implementation
  501. data_dirname: STRING
  502. -- Name of directory containing schematron data files
  503. once
  504. Result := file_system.nested_pathname ("${GOBO}", <<"library", "xslt", "test", "unit", "data">>)
  505. Result := Execution_environment.interpreted_string (Result)
  506. ensure
  507. data_dirname_not_void: Result /= Void
  508. data_dirname_not_empty: not Result.is_empty
  509. end
  510. dummy_uri: UT_URI
  511. -- Dummy URI
  512. once
  513. create Result.make ("dummy:")
  514. ensure
  515. dummy_uri_is_absolute: Result /= Void and then Result.is_absolute
  516. end
  517. format1_xsl_uri: UT_URI
  518. -- URI of file 'format1.xsl'
  519. local
  520. l_path: STRING
  521. once
  522. l_path := file_system.pathname (data_dirname, "format1.xsl")
  523. Result := File_uri.filename_to_uri (l_path)
  524. ensure
  525. format1_xsl_uri_not_void: Result /= Void
  526. end
  527. format2_xsl_uri: UT_URI
  528. -- URI of file 'format2.xsl'
  529. local
  530. l_path: STRING
  531. once
  532. l_path := file_system.pathname (data_dirname, "format2.xsl")
  533. Result := File_uri.filename_to_uri (l_path)
  534. ensure
  535. format2_xsl_uri_not_void: Result /= Void
  536. end
  537. format3_xsl_uri: UT_URI
  538. -- URI of file 'format3.xsl'
  539. local
  540. l_path: STRING
  541. once
  542. l_path := file_system.pathname (data_dirname, "format3.xsl")
  543. Result := File_uri.filename_to_uri (l_path)
  544. ensure
  545. format3_xsl_uri_not_void: Result /= Void
  546. end
  547. format4_xsl_uri: UT_URI
  548. -- URI of file 'format4.xsl'
  549. local
  550. l_path: STRING
  551. once
  552. l_path := file_system.pathname (data_dirname, "format4.xsl")
  553. Result := File_uri.filename_to_uri (l_path)
  554. ensure
  555. format4_xsl_uri_not_void: Result /= Void
  556. end
  557. format5_xsl_uri: UT_URI
  558. -- URI of file 'format5.xsl'
  559. local
  560. l_path: STRING
  561. once
  562. l_path := file_system.pathname (data_dirname, "format5.xsl")
  563. Result := File_uri.filename_to_uri (l_path)
  564. ensure
  565. format5_xsl_uri_not_void: Result /= Void
  566. end
  567. format6_xsl_uri: UT_URI
  568. -- URI of file 'format6.xsl'
  569. local
  570. l_path: STRING
  571. once
  572. l_path := file_system.pathname (data_dirname, "format6.xsl")
  573. Result := File_uri.filename_to_uri (l_path)
  574. ensure
  575. format6_xsl_uri_not_void: Result /= Void
  576. end
  577. format7_xsl_uri: UT_URI
  578. -- URI of file 'format7.xsl'
  579. local
  580. l_path: STRING
  581. once
  582. l_path := file_system.pathname (data_dirname, "format7.xsl")
  583. Result := File_uri.filename_to_uri (l_path)
  584. ensure
  585. format7_xsl_uri_not_void: Result /= Void
  586. end
  587. format_time1_xsl_uri: UT_URI
  588. -- URI of file 'format_time1.xsl'
  589. local
  590. l_path: STRING
  591. once
  592. l_path := file_system.pathname (data_dirname, "format_time1.xsl")
  593. Result := File_uri.filename_to_uri (l_path)
  594. ensure
  595. format_time1_xsl_uri_not_void: Result /= Void
  596. end
  597. format_time2_xsl_uri: UT_URI
  598. -- URI of file 'format_time2.xsl'
  599. local
  600. l_path: STRING
  601. once
  602. l_path := file_system.pathname (data_dirname, "format_time2.xsl")
  603. Result := File_uri.filename_to_uri (l_path)
  604. ensure
  605. format_time2_xsl_uri_not_void: Result /= Void
  606. end
  607. format_time3_xsl_uri: UT_URI
  608. -- URI of file 'format_time3.xsl'
  609. local
  610. l_path: STRING
  611. once
  612. l_path := file_system.pathname (data_dirname, "format_time3.xsl")
  613. Result := File_uri.filename_to_uri (l_path)
  614. ensure
  615. format_time3_xsl_uri_not_void: Result /= Void
  616. end
  617. format_time4_xsl_uri: UT_URI
  618. -- URI of file 'format_time4.xsl'
  619. local
  620. l_path: STRING
  621. once
  622. l_path := file_system.pathname (data_dirname, "format_time4.xsl")
  623. Result := File_uri.filename_to_uri (l_path)
  624. ensure
  625. format_time4_xsl_uri_not_void: Result /= Void
  626. end
  627. format_date_time1_xsl_uri: UT_URI
  628. -- URI of file 'format_date_time1.xsl'
  629. local
  630. l_path: STRING
  631. once
  632. l_path := file_system.pathname (data_dirname, "format_date_time1.xsl")
  633. Result := File_uri.filename_to_uri (l_path)
  634. ensure
  635. format_date_time1_xsl_uri_not_void: Result /= Void
  636. end
  637. format_date_time2_xsl_uri: UT_URI
  638. -- URI of file 'format_date_time2.xsl'
  639. local
  640. l_path: STRING
  641. once
  642. l_path := file_system.pathname (data_dirname, "format_date_time2.xsl")
  643. Result := File_uri.filename_to_uri (l_path)
  644. ensure
  645. format_date_time2_xsl_uri_not_void: Result /= Void
  646. end
  647. end