No matching definitions.

xml/transform

src/xml/transform.tur

rewrite an XML document as it streams past.

Since: 0.2.0

defn

sax-transform-opts

(sax-transform-opts [src : cstr opts : ParseOpts f : (fn [SaxEvent])

transform an in-memory document.

srcthe document
optsparse options (`namespaces`, limits, entities)
fone event in (owned), the events to write out

(Result String TransformError) -- the rewritten document, owned by the caller; InputError when src does not parse, OutputError when the writer refuses what f returned (the parse stops there).

(sax-transform-opts src (with (default-parse-opts) [namespaces false])
                      sax-keep)

Since: 0.2.0

defn

sax-transform

(sax-transform [src : cstr f : (fn [SaxEvent])

transform an in-memory document with the safe default

srcthe document
fone event in (owned), the events to write out

(Result String TransformError)

;; Rename every <item> to <entry>.
  (sax-transform src
    (fn [ev : SaxEvent] : (Cons SaxEvent)
      (match ev
        (StartElement n as) (if (string=? n "item")
                              (do (release n)
                                  (tcons-of (StartElement (from-cstr "entry") as) (tnil)))
                              (sax-keep ev))
        (EndElement n)      (if (string=? n "item")
                              (do (release n)
                                  (tcons-of (EndElement (from-cstr "entry")) (tnil)))
                              (sax-keep ev))
        _                   (sax-keep ev))))

Since: 0.2.0

defn

sax-transform-file

(sax-transform-file [in-path : cstr out-path : cstr opts : ParseOpts f : (fn [SaxEvent])

transform a file into another, streaming both.

in-paththe document to read
out-paththe file to write (created or truncated)
optsparse options
fone event in (owned), the events to write out

(Result nil TransformError) -- OutputError (IoFailed) when out-path cannot be created or written.

(sax-transform-file "in.xml" "out.xml" (default-parse-opts) sax-keep)

Since: 0.2.0

Internal definitions
__xt-finish-- internal: the parse's outcome, then the writer's.