A set of reusable XSLT components.
A set of reusable XSLT components.
Write and execute XSLT transformations with Clojure.
Scenario:
xsl:element
.For example, you want to transform this:
<a xmlns="my-ns"/>
To this:
<b xmlns="my-ns"/>
In your XSLT transformation, you want to write something like this:
(xsl/template {:match "a"} [:b])
Instead of this:
(xsl/template {:match "a"}
(xsl/element {:name "b"}))
If you create a literal element with [:b]
, though, clojure.data.xml puts it
into the empty namespace. That means that the XSLT stylesheet Sigel produces
will have this:
<xsl:template match="a">
<!-- note the empty xmlns namespace declaration -->
<b xmlns=""/>
</xsl:template>
When what you actually want is this:
<xsl:template match="a">
<b/>
</xsl:template>
To do that, you must first set up your namespace with
clojure.data.xml/alias-uri
:
(xml/alias-uri 'my-ns "my-ns-uri")
You then need to set the xmlns
attribute of your stylesheet and use the
my-ns
prefix when emitting literal XML elements:
(xsl/stylesheet {:version 3.0 :xmlns "my-ns-uri"}
(xsl/template {:match "a"} [::my-ns/b]))
Write and execute XSLT transformations with Clojure. ## XML namespaces Scenario: - Your source XML document is in an XML namespace. - You want to transform that document with Sigel into the same namespace. - You want to write literal XML elements in your transformation, instead of using `xsl:element`. For example, you want to transform this: ```xml <a xmlns="my-ns"/> ``` To this: ```xml <b xmlns="my-ns"/> ``` In your XSLT transformation, you want to write something like this: ``` (xsl/template {:match "a"} [:b]) ``` Instead of this: ``` (xsl/template {:match "a"} (xsl/element {:name "b"})) ``` If you create a literal element with `[:b]`, though, clojure.data.xml puts it into the empty namespace. That means that the XSLT stylesheet Sigel produces will have this: ```xml <xsl:template match="a"> <!-- note the empty xmlns namespace declaration --> <b xmlns=""/> </xsl:template> ``` When what you actually want is this: ```xml <xsl:template match="a"> <b/> </xsl:template> ``` To do that, you must first set up your namespace with `clojure.data.xml/alias-uri`: ```clojure (xml/alias-uri 'my-ns "my-ns-uri") ``` You then need to set the `xmlns` attribute of your stylesheet and use the `my-ns` prefix when emitting literal XML elements: ```clojure (xsl/stylesheet {:version 3.0 :xmlns "my-ns-uri"} (xsl/template {:match "a"} [::my-ns/b])) ```
Functions for creating XSLT elements.
This namespace declares so many vars that conflict with vars in the Clojure core that you probably want to alias the vars in this namespace.
The docstrings in this file are copied directly from the Saxon documentation.
Functions for creating XSLT elements. This namespace declares so many vars that conflict with vars in the Clojure core that you probably want to alias the vars in this namespace. The docstrings in this file are copied directly from [the Saxon documentation](http://www.saxonica.com/html/documentation/xsl-elements).
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close