]> gitweb.factorcode.org Git - factor.git/commitdiff
Revert "xml: Changing how we represent contained-tags"
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 12 Feb 2022 16:43:24 +0000 (08:43 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 12 Feb 2022 16:43:24 +0000 (08:43 -0800)
This reverts commit b56d3314b12f7aa223925f97f56cc5faaa7da778.

basis/xml/data/data.factor
basis/xml/syntax/syntax-docs.factor
basis/xml/syntax/syntax-tests.factor
basis/xml/writer/writer-tests.factor
basis/xml/xml.factor

index 801d6bf328ba97cf452a44aaddf96ba736acfa90..bb948e159beb5f06c908a0cb95f21c05401fe8cb 100644 (file)
@@ -216,8 +216,8 @@ M: xml like
 : <contained-tag> ( name attrs -- tag )
     f <tag> ;
 
-PREDICATE: contained-tag < tag children>> >boolean not ;
-PREDICATE: open-tag < tag children>> >boolean ;
+PREDICATE: contained-tag < tag children>> empty? ;
+PREDICATE: open-tag < tag children>> empty? not ;
 
 TUPLE: unescaped string ;
 C: <unescaped> unescaped
index 87afb8694a1769630862b8128871872461ad231a..23d81b174d0bfa8f9eee193e254ddd5bc42fcd3a 100644 (file)
@@ -54,7 +54,7 @@ ARTICLE: { "xml.syntax" "interpolation" } "XML interpolation syntax"
 $nl
 "These forms can be used where a tag might go, as in " { $snippet "[XML <foo><-></foo> XML]" } " or where an attribute might go, as in " { $snippet "[XML <foo bar=<->/> XML]" } ". When an attribute is spliced in, it is not included if the value is " { $snippet "f" } " and if the value is not a string, the value is put through " { $link present } ". Here is an example of the fry style of XML interpolation:"
 { $example
-"USING: sequences splitting xml.writer xml.syntax ;
+"USING: splitting xml.writer xml.syntax ;
 \"one two three\" \" \" split
 [ [XML <item><-></item> XML] ] map
 <XML <doc><-></doc> XML> pprint-xml"
@@ -73,7 +73,7 @@ $nl
 </doc>" }
 "Here is an example of the locals version:"
 { $example
-"USING: kernel locals urls xml.syntax xml.writer ;
+"USING: locals urls xml.syntax xml.writer ;
 [let
     3 :> number
     f :> false
@@ -93,7 +93,7 @@ $nl
 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
 <x number=\"3\" url=\"http://factorcode.org/\" string=\"hello\" word=\"drop\"/>" }
 "XML interpolation can also be used, in conjunction with " { $vocab-link "inverse" } " in pattern matching. For example:"
-{ $unchecked-example "USING: xml.syntax inverse ;
+{ $example "USING: xml.syntax inverse ;
 : dispatch ( xml -- string )
     {
         { [ [XML <a><-></a> XML] ] [ \"a\" prepend ] }
index a95dd8dff4317fa956c423d37eac84900f2013e8..e002c3fb99c29b7295589cbd4a690f8a7c1dd8ef 100644 (file)
@@ -43,8 +43,8 @@ XML-NS: foo http://blah.com
 { "a" "c" { "a" "c" f } } [
     "<?xml version='1.0'?><x><-a-><b val=<-c->/><-></x>"
     string>doc
-    [ first var>> ]
-    [ second "val" attr var>> ]
+    [ second var>> ]
+    [ fourth "val" attr var>> ]
     [ extract-variables ] tri
 ] unit-test
 
index badb4c073afe6979f8ffbb79dce7f2923ea9c580..d12e530ee7dafd96ffa8ec442957536e02fe4aa8 100644 (file)
@@ -78,5 +78,5 @@ IN: xml.writer.tests
 ] unit-test
 
 { "<test name=\"bob\"/>" } [
-    "test" { { "name" "bob" } } <contained-tag> xml>string
+    "test" { { "name" "bob" } } { } <tag> xml>string
 ] unit-test
index c2dfcb7beac4d084aec9c8750fa3b79f9d1cb674..b1e7d71429f959050e4fb645454c8b31ee95e7e9 100644 (file)
@@ -4,8 +4,8 @@ USING: accessors arrays ascii assocs combinators
 combinators.short-circuit io io.encodings.binary
 io.encodings.utf8 io.files io.streams.byte-array
 io.streams.string kernel namespaces sequences splitting strings
-vectors xml.autoencoding xml.data xml.elements xml.errors
-xml.name xml.state xml.tokenize ;
+xml.autoencoding xml.data xml.elements xml.errors xml.name
+xml.state xml.tokenize ;
 IN: xml
 
 <PRIVATE
@@ -23,8 +23,6 @@ GENERIC: process ( object -- )
 
 M: object process add-child ;
 
-M: string process [ add-child ] unless-empty ;
-
 M: prolog process
     xml-stack get
     { V{ { f V{ "" } } } V{ { f V{ } } } } member?
@@ -186,7 +184,7 @@ PRIVATE>
     } case ;
 
 : read-xml-chunk ( stream -- seq )
-    [ check ] 1 read-seq dup empty? [ "" suffix! ] when <xml-chunk> ;
+    [ check ] 1 read-seq <xml-chunk> ;
 
 : string>xml ( string -- xml )
     <string-reader> read-xml ;