diff --git a/extra/xml/utilities/utilities.factor b/extra/xml/utilities/utilities.factor index 303de4295e..2bd37dc104 100644 --- a/extra/xml/utilities/utilities.factor +++ b/extra/xml/utilities/utilities.factor @@ -36,14 +36,16 @@ M: process-missing error. ! * Common utility functions : build-tag* ( items name -- tag ) - "" swap "" - swap >r { } r> ; + assure-name swap >r f r> ; : build-tag ( item name -- tag ) >r 1array r> build-tag* ; +: standard-prolog ( -- prolog ) + T{ prolog f "1.0" "iso-8859-1" f } ; + : build-xml ( tag -- xml ) - T{ prolog f "1.0" "iso-8859-1" f } { } rot { } ; + standard-prolog { } rot { } ; : children>string ( tag -- string ) tag-children @@ -138,3 +140,10 @@ M: xml xml-inject >r delegate >r xml-inject ; : assert-tag ( name name -- ) names-match? [ "Unexpected XML tag found" throw ] unless ; + +: insert-children ( children tag -- ) + dup tag-children [ push-all ] + [ >r V{ } like r> set-tag-children ] if ; + +: insert-child ( child tag -- ) + >r 1vector r> insert-children ;