xml.traversal: adding deep-children>string.
parent
589af77192
commit
07194b7a13
|
|
@ -9,6 +9,8 @@ IN: xml.traversal.tests
|
||||||
|
|
||||||
[ "" ] [ "<foo/>" string>xml children>string ] unit-test
|
[ "" ] [ "<foo/>" string>xml children>string ] unit-test
|
||||||
|
|
||||||
|
[ "bar qux" ] [ "<foo>bar <baz>qux</baz></foo>" string>xml deep-children>string ] unit-test
|
||||||
|
|
||||||
[ "blah" ] [ "<foo attr='blah'/>" string>xml-chunk "foo" deep-tag-named "attr" attr ] unit-test
|
[ "blah" ] [ "<foo attr='blah'/>" string>xml-chunk "foo" deep-tag-named "attr" attr ] unit-test
|
||||||
|
|
||||||
[ { "blah" } ] [ "<foo attr='blah'/>" string>xml-chunk "foo" deep-tags-named [ "attr" attr ] map ] unit-test
|
[ { "blah" } ] [ "<foo attr='blah'/>" string>xml-chunk "foo" deep-tags-named [ "attr" attr ] map ] unit-test
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2005, 2009 Daniel Ehrenberg
|
! Copyright (C) 2005, 2009 Daniel Ehrenberg
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel namespaces sequences words io assocs
|
USING: accessors kernel namespaces sequences words io assocs
|
||||||
quotations strings parser lexer arrays xml.data
|
quotations strings parser lexer arrays xml.data make
|
||||||
splitting vectors sequences.deep combinators fry memoize ;
|
splitting vectors sequences.deep combinators fry memoize ;
|
||||||
IN: xml.traversal
|
IN: xml.traversal
|
||||||
|
|
||||||
|
|
@ -15,6 +15,11 @@ IN: xml.traversal
|
||||||
[ concat ]
|
[ concat ]
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
|
: deep-children>string ( tag -- string )
|
||||||
|
children>> [
|
||||||
|
[ dup tag? [ deep-children>string ] when % ] each
|
||||||
|
] "" make ;
|
||||||
|
|
||||||
: children-tags ( tag -- sequence )
|
: children-tags ( tag -- sequence )
|
||||||
children>> [ tag? ] filter ;
|
children>> [ tag? ] filter ;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue