|
41 | 41 |
|
42 | 42 | (deftest test-xml-with-whitespace |
43 | 43 | (let [input (str "<a>\n<b with-attr=\"s p a c e\">123</b>\n<c>1 2 3</c>\n\n</a>") |
44 | | - expected (element :a {} |
45 | | - (element :b {:with-attr "s p a c e"} "123") |
46 | | - (element :c {} "1 2 3"))] |
| 44 | + expected (element :a {} |
| 45 | + "\n" |
| 46 | + (element :b {:with-attr "s p a c e"} "123") |
| 47 | + "\n" |
| 48 | + (element :c {} "1 2 3") |
| 49 | + "\n\n")] |
47 | 50 | (is (= expected (lazy-parse* input))))) |
48 | 51 |
|
49 | 52 | (deftest test-cdata-parse |
|
89 | 92 | (is (= 1 (-> input parse-str location-meta :column-number))) |
90 | 93 | (is (= 1 (-> input parse-str :content first location-meta :line-number))) |
91 | 94 | (is (= 4 (-> input parse-str :content first location-meta :column-number))) |
92 | | - (is (= 2 (-> input parse-str :content second location-meta :line-number))) |
| 95 | + (is (= 2 (-> input (parse-str :skip-whitespace true) :content second location-meta :line-number))) |
93 | 96 | (is (nil? (-> input |
94 | 97 | (parse-str :location-info false) |
95 | 98 | location-meta))))) |
| 99 | + |
| 100 | +(deftest test-ignorable-whitespace |
| 101 | + ;; FIXME implement clojure.lang.MapEquivalence for records |
| 102 | + (clojure.lang.APersistentMap/mapEquals |
| 103 | + (parse-str "<?xml version=\"1.0\"?> |
| 104 | +<!DOCTYPE methodCall [ |
| 105 | + <!ELEMENT methodCall (methodName, params)> |
| 106 | + <!ELEMENT params (param+)> |
| 107 | + <!ELEMENT param (value)> |
| 108 | + <!ELEMENT value (string)> |
| 109 | + <!ELEMENT methodName (#PCDATA)> |
| 110 | + <!ELEMENT string (#PCDATA)> |
| 111 | +]> |
| 112 | +<methodCall> |
| 113 | + <methodName>lookupSymbol</methodName> |
| 114 | + <params> |
| 115 | + <param> |
| 116 | + <value> |
| 117 | + <string> |
| 118 | + Clojure XML <3 |
| 119 | + </string> |
| 120 | + </value> |
| 121 | + </param> |
| 122 | + </params> |
| 123 | +</methodCall>") |
| 124 | + {:tag :methodCall, :attrs {}, :content |
| 125 | + [{:tag :methodName, :attrs {}, :content |
| 126 | + ["lookupSymbol"]} |
| 127 | + {:tag :params, :attrs {}, :content |
| 128 | + [{:tag :param, :attrs {}, :content |
| 129 | + [{:tag :value, :attrs {}, :content |
| 130 | + [{:tag :string, :attrs {}, :content |
| 131 | + ["\n Clojure XML <3 \n "]}]}]}]}]})) |
0 commit comments