! See http://factorcode.org/license.txt for BSD license.\r
USING: hashtables kernel math namespaces sequences strings\r
assocs combinators io io.streams.string accessors\r
-xml.data wrap xml.entities unicode.categories fry ;\r
+xml.data wrap.strings xml.entities unicode.categories fry ;\r
IN: xml.writer\r
\r
SYMBOL: sensitive-tags\r
\r
: indent-string ( -- string )\r
xml-pprint? get\r
- [ indentation get indenter get <repetition> concat ]\r
+ [ indentation get indenter get <repetition> "" concat-as ]\r
[ "" ] if ;\r
\r
: ?indent ( -- )\r
: unindent ( -- )\r
xml-pprint? get [ -1 indentation +@ ] when ;\r
\r
-: trim-whitespace ( string -- no-whitespace )\r
- [ blank? ] trim ;\r
-\r
: ?filter-children ( children -- no-whitespace )\r
xml-pprint? get [\r
- [ dup string? [ trim-whitespace ] when ] map\r
- [ [ empty? ] [ string? ] bi and not ] filter\r
+ [ dup string? [ [ blank? ] trim ] when ] map\r
+ [ "" = ] reject\r
] when ;\r
\r
PRIVATE>\r
\r
M: doctype-decl write-xml\r
?indent "<!DOCTYPE " write\r
- [ name>> write " " write ]\r
- [ external-id>> [ write-xml " " write ] when* ]\r
+ [ name>> write bl ]\r
+ [ external-id>> [ write-xml bl ] when* ]\r
[ internal-subset>> write-internal-subset ">" write ] tri ;\r
\r
M: directive write-xml\r
M: prolog write-xml\r
"<?xml version=" write\r
[ version>> write-quoted ]\r
- [ " encoding=" write encoding>> write-quoted ]\r
+ [ drop " encoding=\"UTF-8\"" write ]\r
[ standalone>> [ " standalone=\"yes\"" write ] when ] tri\r
"?>" write ;\r
\r