USING: kernel xml sequences assocs tools.test io arrays namespaces fry accessors xml.data xml.traversal xml.writer generic sequences.deep multiline ; IN: xml.tests CONSTANT: sub-tag T{ name f f "sub" "http://littledan.onigirihouse.com/namespaces/replace" } SYMBOL: ref-table GENERIC: (r-ref) ( xml -- ) M: tag (r-ref) dup sub-tag attr [ ref-table get at >>children drop ] [ drop ] if* ; M: object (r-ref) drop ; : template ( xml -- ) [ (r-ref) ] deep-each ; ! Example STRING: sample-doc
paragraph
; STRING: expected-result foo ; : test-refs ( -- string ) [ H{ { "foo" { "foo" } } { "bar" { "blah" T{ tag f T{ name f "" "a" "" } T{ attrs } f } } } { "baz" f } } ref-table set sample-doc string>xml dup template pprint-xml>string ] with-scope ; expected-result '[ _ ] [ test-refs ] unit-test