diff --git a/basis/xml/dispatch/dispatch.factor b/basis/xml/dispatch/dispatch.factor index 613836aae2..9c4a2448c6 100644 --- a/basis/xml/dispatch/dispatch.factor +++ b/basis/xml/dispatch/dispatch.factor @@ -9,7 +9,7 @@ M: no-tag summary drop "The tag-dispatching word has no method for the given tag name" ; : compile-tags ( word xtable -- quot ) - >alist swap '[ _ no-tag boa throw ] [ ] like suffix + >alist swap '[ _ no-tag boa throw ] suffix '[ dup main>> _ case ] ; : define-tags ( word -- ) diff --git a/basis/xml/tests/test.factor b/basis/xml/tests/test.factor index 337c19bfe1..dcd428d9e6 100644 --- a/basis/xml/tests/test.factor +++ b/basis/xml/tests/test.factor @@ -67,3 +67,4 @@ SYMBOL: xml-file [ "x" "<" ] [ "" string>xml [ name>> main>> ] [ "value" attr ] bi ] unit-test [ "foo" ] [ "]>&bar;" string>xml children>string ] unit-test [ T{ xml-chunk f V{ "hello" } } ] [ "hello" string>xml-chunk ] unit-test +[ "1.1" ] [ "" string>xml prolog>> version>> ] unit-test diff --git a/basis/xml/writer/writer-tests.factor b/basis/xml/writer/writer-tests.factor index d09ae08b3f..f414264e11 100644 --- a/basis/xml/writer/writer-tests.factor +++ b/basis/xml/writer/writer-tests.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2005, 2009 Daniel Ehrenberg ! See http://factorcode.org/license.txt for BSD license. USING: xml.data xml.writer tools.test fry xml kernel multiline -xml.writer.private io.streams.string xml.utilities sequences ; +xml.writer.private io.streams.string xml.utilities sequences +io.encodings.utf8 io.files accessors io.directories ; IN: xml.writer.tests \ write-xml must-infer @@ -59,3 +60,9 @@ IN: xml.writer.tests [ "\n\n bar\n" ] [ " bar " string>xml pprint-xml>string ] unit-test [ "" ] [ "" xml>string ] unit-test + +: test-file "resource:basis/xml/writer/test.xml" ; + +[ ] [ "" string>xml test-file utf8 [ write-xml ] with-file-writer ] unit-test +[ "x" ] [ test-file file>xml body>> name>> main>> ] unit-test +[ ] [ test-file delete-file ] unit-test diff --git a/basis/xml/writer/writer.factor b/basis/xml/writer/writer.factor index a713790973..4b80e0818e 100755 --- a/basis/xml/writer/writer.factor +++ b/basis/xml/writer/writer.factor @@ -164,7 +164,7 @@ M: sequence write-xml M: prolog write-xml "> write-quoted ] - [ " encoding=" write encoding>> write-quoted ] + [ drop " encoding=\"UTF-8\"" write ] [ standalone>> [ " standalone=\"yes\"" write ] when ] tri "?>" write ; diff --git a/basis/xml/xml.factor b/basis/xml/xml.factor index 5ca486a57f..57c1b6dbd3 100755 --- a/basis/xml/xml.factor +++ b/basis/xml/xml.factor @@ -4,7 +4,7 @@ USING: accessors arrays io io.encodings.binary io.files io.streams.string kernel namespaces sequences strings io.encodings.utf8 xml.data xml.errors xml.elements ascii xml.entities xml.writer xml.state xml.autoencoding assocs xml.tokenize -combinators.short-circuit xml.name ; +combinators.short-circuit xml.name splitting ; IN: xml ; + dup [ tag? ] find [ + assure-tags cut + [ cut-prolog ] [ rest ] bi* + no-pre/post no-post-tags + ] dip swap ; ! * Views of XML