Merge pull request #1231 from simmone/xml

not sort xml attributes
This commit is contained in:
Jay McCarthy 2016-02-03 11:07:02 -05:00
commit ced25315ac
2 changed files with 16 additions and 11 deletions

View File

@ -463,6 +463,12 @@ END
"<a href=\"#\">inner</a>"
'(a ([href "#"]) "inner"))
(test-syntax:read-xml/element
"<a c=\"1\" a=\"2\" b=\"3\">inner</a>"
'(a ([c "1"] [a "2"] [b "3"]) "inner"))
(test-syntax:read-xml/element/exn "<a c=\"1\" a=\"2\" c=\"3\">inner</a>" "read-xml: lex-error: at position 1.20/21: duplicated attribute name c")
(test-syntax:read-xml/element
"<root>&nbsp;</root>"
'(root () nbsp))

View File

@ -270,17 +270,16 @@
;; lex-attributes : Input-port (-> Location) -> (listof Attribute)
(define (lex-attributes in pos)
(sort (let loop ()
(skip-space in)
(cond [(name-start? (peek-char-or-special in))
(cons (lex-attribute in pos) (loop))]
[else null]))
(lambda (a b)
(let ([na (attribute-name a)]
[nb (attribute-name b)])
(cond
[(eq? na nb) (lex-error in pos "duplicated attribute name ~a" na)]
[else (string<? (symbol->string na) (symbol->string nb))])))))
(let* ([result_list
(let loop ()
(skip-space in)
(cond [(name-start? (peek-char-or-special in))
(cons (lex-attribute in pos) (loop))]
[else null]))]
[check_dup (check-duplicates result_list (lambda (a b) (eq? (attribute-name a) (attribute-name b))))])
(if check_dup
(lex-error in pos "duplicated attribute name ~a" (attribute-name check_dup))
result_list)))
;; lex-attribute : Input-port (-> Location) -> Attribute
(define (lex-attribute in pos)