]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/xml/writer/writer.factor
use reject instead of [ ... not ] filter.
[factor.git] / basis / xml / writer / writer.factor
old mode 100755 (executable)
new mode 100644 (file)
index 4b80e08..0243ede
@@ -2,7 +2,7 @@
 ! 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
@@ -19,7 +19,7 @@ SYMBOL: indentation
 \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
@@ -31,13 +31,10 @@ SYMBOL: indentation
 : 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
@@ -145,8 +142,8 @@ M: public-id write-xml
 \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