-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I frequently find myself utilizing hiccup-style data structures rather than strings/streams. Something like:
[:list
[:token "defproject"]
[:whitespace " "]...
]
In the past, I would convert it into a string and then perform my XSLT transformations. However, more recently, I crafted a straightforward wrapper around TinyBuilder.
(defn xml-document [tree]
(let [processor (Processor. false)
configuration (.getUnderlyingConfiguration processor)
builder (TinyBuilder. (.makePipelineConfiguration configuration))
walk (fn walk [x]
(if (coll? x)
(do
(.startElement builder (FingerprintedQName. "" "" (name (first x))) (Untyped/getInstance) ExplicitLocation/UNKNOWN_LOCATION 0)
(run! walk (rest x))
(.endElement builder))
(.characters builder x ExplicitLocation/UNKNOWN_LOCATION 0)))]
(.open builder)
(.startDocument builder 0)
(walk tree)
(.close builder)
(.getRootNode (.getTree builder))))
At present, it does not have the capability to handle attributes.
Would you be interested in incorporating this code into your library once it is completed?
Metadata
Metadata
Assignees
Labels
No labels