Skip to content

Commit 19bbfee

Browse files
committed
CHANGE: XML codec by default does not trim/remove strings between tags.
Example: ``` third codecs/xml/decode {<a> <b/> </a>} ;== [["a" none [" " ["b" none none] " "]]] third codecs/xml/decode/trim {<a> <b/> </a>} ;== [["a" none [["b" none none]]]] ```
1 parent e71a808 commit 19bbfee

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/mezz/codec-xml.r

+11-13
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,18 @@ register-codec [
178178
decode: function [
179179
"Parses XML code and returns a tree of blocks"
180180
data [binary! string!] "XML code to parse"
181-
/no-trim "Don't removes whitespaces"
181+
/trim "Removes whitespaces (from head of strings)"
182182
][
183183
if binary? data [data: to string! data]
184-
do bind [
185-
xmlTrimSpace: either any [
186-
no-trim
187-
all [
188-
block? options
189-
find options 'no-trim
190-
]
191-
] [none][[any xmlSpace]]
192-
parse-xml data
193-
] parser
184+
parser/xmlTrimSpace: any [
185+
trim
186+
select options 'trim
187+
]
188+
parser/parse-xml data
194189
]
195190

196191
verbose: 0 ;not used so far, but could be later
197-
options: none
192+
options: object [trim: false]
198193

199194

200195
;-- follows content of the original xml-parse object:
@@ -988,7 +983,7 @@ register-codec [
988983
(element-q-name: element-ns-prefix: "")
989984
]
990985
]
991-
xmlTrimSpace: none
986+
xmlTrimSpace: none ;- no trim by default
992987
;
993988
;
994989
; Private XML Parser Methods
@@ -1038,6 +1033,9 @@ register-codec [
10381033
xml-string [string!]
10391034
/local parse-result
10401035
][
1036+
1037+
if true? xmlTrimSpace [xmlTrimSpace: [any xmlSpace]]
1038+
10411039
;
10421040
; Parse the document and capture the return code from the REBOL
10431041
; parse.

0 commit comments

Comments
 (0)