xml-test.scm 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. (test-begin "xml")
  2. (require "test-utils.scm")
  3. (xtest #<a id="mine"/>
  4. '($xml-element$ () ($resolve-qname$ a)
  5. ($xml-attribute$ 'id "mine"))
  6. &{<a id="mine"></a>})
  7. (xtest #<x:a xmlns:x="X" x:id="mine">text</x:a>
  8. '($xml-element$ ((x "X")) ($resolve-qname$ a x)
  9. ($xml-attribute$ ($resolve-qname$ id x) "mine")
  10. "text")
  11. &{<x:a xmlns:x="X" x:id="mine">text</x:a>})
  12. (xtest #<a xmlns="X" id="mine"/>
  13. '($xml-element$ ((|| "X")) ($resolve-qname$ a)
  14. ($xml-attribute$ 'id "mine"))
  15. &{<a xmlns="X" id="mine" />})
  16. (let ((xid 'id)
  17. (xa 'a)
  18. (xine "ine")
  19. (xtex "tex"))
  20. (xtest #<[xa] [xid]="m&[xine]">&[xtex]t</>
  21. '($xml-element$ () xa
  22. ($xml-attribute$ xid "m" $<<$ xine $>>$)
  23. $<<$ xtex $>>$ "t")
  24. &{<a id="mine">text</a>}))
  25. ;; Computed attribute value.
  26. (let ((idatr ($xml-attribute$ 'id "myId")))
  27. (xtest #<ab [idatr] x="name"/>
  28. '($xml-element$ () ($resolve-qname$ ab)
  29. idatr ($xml-attribute$ 'x "name"))
  30. &{<ab id="myId" x="name"></ab>}))
  31. (let ((val1 "VAL1"))
  32. (xtest #<ab at1=[val1] at2=[val1 "/" val1] at3=(string-downcase val1)/>
  33. '($xml-element$ () ($resolve-qname$ ab)
  34. ($xml-attribute$ (quote at1) val1)
  35. ($xml-attribute$ (quote at2) val1 "/" val1)
  36. ($xml-attribute$ (quote at3) (string-downcase val1)))
  37. &{<ab at1="VAL1" at2="VAL1/VAL1" at3="val1"></ab>}))
  38. ;; Test &#|comment|#
  39. (xtest #<ab id="n&#|comment1|#ame">12&#|comment2|#9</>
  40. '($xml-element$ () ($resolve-qname$ ab)
  41. ($xml-attribute$ (quote id) "name") "129")
  42. &{<ab id="name">129</ab>})
  43. ;; Test line-continuation &- in both attribute and element content.
  44. (xtest #<em id="na&-
  45. me">abc&-
  46. def</em>
  47. '($xml-element$ () ($resolve-qname$ em)
  48. ($xml-attribute$ (quote id) "name") "abc def")
  49. &{<em id="name">abc def</em>})
  50. (xtest #<em>
  51. &|abc
  52. &| def</em>
  53. '($xml-element$ () ($resolve-qname$ em) "abc\n def")
  54. &{<em>abc&newline; def</em>})
  55. (test-end)