A bunch of utility functions for xml documents
A bunch of utility functions for xml documents
(edn->xml edn)
(edn->xml edn {:keys [stringify-values?] :as opts})
Transform an EDN data structure to the pseudo XML expected by clojure.data.xml
.
To change the default behavior, an option map may be provided with the following keys:
to-xml-case? - To modify the keys representing XML tags to XML_CASE
from-xml-case? - If the source EDN has XML_CASE keys
stringify-values? - to coerce non-nil, non-string, non-collection values to strings
Transform an EDN data structure to the pseudo XML expected by `clojure.data.xml`. To change the default behavior, an option map may be provided with the following keys: to-xml-case? - To modify the keys representing XML tags to XML_CASE from-xml-case? - If the source EDN has XML_CASE keys stringify-values? - to coerce non-nil, non-string, non-collection values to strings
(edn->xml-str edn)
(edn->xml-str edn {:keys [:encoding :doctype] :as opts})
Transform an EDN data structure into an XML string via clojure.data.xml
.
To change the default behavior, an option map may be provided with the following keys: to-xml-case? - To modify the keys representing XML tags to XML_CASE from-xml-case? - If the source EDN has XML_CASE keys stringify-values? - to coerce non-nil, non-string, non-collection values to strings
It also surfaces the original options from clojure.data.xml/emit-str
encoding - The character encoding to use
doctype - The DOCTYPE declaration to use
Transform an EDN data structure into an XML string via `clojure.data.xml`. To change the default behavior, an option map may be provided with the following keys: to-xml-case? - To modify the keys representing XML tags to XML_CASE from-xml-case? - If the source EDN has XML_CASE keys stringify-values? - to coerce non-nil, non-string, non-collection values to strings It also surfaces the original options from `clojure.data.xml/emit-str` encoding - The character encoding to use doctype - The DOCTYPE declaration to use
(edn->xml-stream edn java-writer)
(edn->xml-stream edn java-writer {:keys [:encoding :doctype] :as opts})
Transform an EDN data structure into XML and stream is out via clojure.data.xml
.
To change the default behavior, an option map may be provided with the following keys: to-xml-case? - To modify the keys representing XML tags to XML_CASE from-xml-case? - If the source EDN has XML_CASE keys stringify-values? - to coerce non-nil, non-string, non-collection values to strings
It also surfaces the original options from clojure.data.xml/emit
encoding - The character encoding to use
doctype - The DOCTYPE declaration to use
Transform an EDN data structure into XML and stream is out via `clojure.data.xml`. To change the default behavior, an option map may be provided with the following keys: to-xml-case? - To modify the keys representing XML tags to XML_CASE from-xml-case? - If the source EDN has XML_CASE keys stringify-values? - to coerce non-nil, non-string, non-collection values to strings It also surfaces the original options from `clojure.data.xml/emit` encoding - The character encoding to use doctype - The DOCTYPE declaration to use
(edn-map->xml edn)
(edn-map->xml edn
{:keys [to-xml-case? from-xml-case? stringify-values?] :as opts})
Transform an EDN map to the pseudo XML expected by clojure.data.xml
.
To change the default behavior, an option map may be provided with the following keys:
to-xml-case? - To modify the keys representing XML tags to XML_CASE
from-xml-case? - If the source EDN has XML_CASE keys
stringify-values? - to coerce non-nil, non-string, non-collection values to strings
Transform an EDN map to the pseudo XML expected by `clojure.data.xml`. To change the default behavior, an option map may be provided with the following keys: to-xml-case? - To modify the keys representing XML tags to XML_CASE from-xml-case? - If the source EDN has XML_CASE keys stringify-values? - to coerce non-nil, non-string, non-collection values to strings
(edn-seq->xml edn)
(edn-seq->xml edn opts)
Transform an EDN sequence to the pseudo XML expected by clojure.data.xml
.
To change the default behavior, an option map may be provided with the following keys:
to-xml-case? - To modify the keys representing XML tags to XML_CASE
from-xml-case? - If the source EDN has XML_CASE keys
stringify-values? - to coerce non-nil, non-string, non-collection values to strings
Transform an EDN sequence to the pseudo XML expected by `clojure.data.xml`. To change the default behavior, an option map may be provided with the following keys: to-xml-case? - To modify the keys representing XML tags to XML_CASE from-xml-case? - If the source EDN has XML_CASE keys stringify-values? - to coerce non-nil, non-string, non-collection values to strings
An alias for the ::every namespaced keyword
An alias for the ::every namespaced keyword
An alias for the ::first namespaced keyword
An alias for the ::first namespaced keyword
(force-xml-seq-at-path xml-edn [key & key-seq])
Update xml-edn
to convert the specified child node in the key path to a vector.
key-paths
is a sequence of key
and key-seq
, each of which is either a bare keywords or the following namespaced keywords:
key-path
, force-xml-seq-at-path
will traverse xml-edn
one levelUpdate `xml-edn` to convert the specified child node in the key path to a vector. `key-paths` is a sequence of `key` and `key-seq`, each of which is either a bare keywords or the following namespaced keywords: - ::every or the alias every-child - ::first or the alias first-child - ::last or the alias last-child For each element in `key-path`, `force-xml-seq-at-path` will traverse `xml-edn` one level - If the current node is a map, clj-xml expects a keyword to update - If the current node is a sequence, clj-xml expects one of the supplied namespaced keywords and will update the related members of that sequence
(force-xml-seq-at-paths xml-edn key-paths)
Convert every path specified in key-paths
within xml-edn
to convert the specified child node to a vector.
key-paths
is a sequence of sequences, each of which contains a mixture of bare keywords or the following namespaced keywords:
key-path
, force-xml-seq-at-paths
will traverse xml-edn
one levelConvert every path specified in `key-paths` within `xml-edn` to convert the specified child node to a vector. `key-paths` is a sequence of sequences, each of which contains a mixture of bare keywords or the following namespaced keywords: - ::every or the alias every-child - ::first or the alias first-child - ::last or the alias last-child For each element in `key-path`, `force-xml-seq-at-paths` will traverse `xml-edn` one level - If the current node is a map, clj-xml expects a keyword to update - If the current node is a sequence, clj-xml expects one of the supplied namespaced keywords and will update the related members of that sequence
An alias for the ::last namespaced keyword
An alias for the ::last namespaced keyword
(xml->edn xml-doc)
(xml->edn xml-doc {:keys [stringify-values?] :as opts})
Transform an XML document as formatted by clojure.xml/parse
, and transform it into normalized EDN.
By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags.
To change this behavior, an option map may be provided with the following keys:
preserve-keys? - A boolean, that if set to true, maintains the exact keyword structure provided by clojure.xml/parse
preserve-attrs? - A boolean, that if set to true, maintains embedded XML attributes
stringify-values? - A boolean, that if set to true, coerces non-nil, non-string, non-collection values to strings
remove-empty-attrs? - A boolean, that if set to true, removes any empty attribute maps
force-seq? - A boolean, that if set to true, coerces child XML nodes into a sequence of maps
Transform an XML document as formatted by `clojure.xml/parse`, and transform it into normalized EDN. By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags. To change this behavior, an option map may be provided with the following keys: preserve-keys? - A boolean, that if set to true, maintains the exact keyword structure provided by `clojure.xml/parse` preserve-attrs? - A boolean, that if set to true, maintains embedded XML attributes stringify-values? - A boolean, that if set to true, coerces non-nil, non-string, non-collection values to strings remove-empty-attrs? - A boolean, that if set to true, removes any empty attribute maps force-seq? - A boolean, that if set to true, coerces child XML nodes into a sequence of maps
(xml->edn' xml-doc)
(xml->edn' xml-doc {:keys [force-seq-for-paths] :as opts})
Wrapper around xml->edn to apply sequence coercion
Wrapper around xml->edn to apply sequence coercion
(xml-map->edn xml-map)
(xml-map->edn {:keys [tag attrs content]}
{:keys [preserve-keys? preserve-attrs? stringify-values?
remove-empty-attrs?]
:as opts})
Transform an XML map as formatted by clojure.xml/parse
, and transform it into normalized EDN.
By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags.
To change this behavior, an option map be provided with the following keys:
preserve-keys? - to maintain the exact keyword structure provided by clojure.xml/parse
preserve-attrs? - to maintain embedded XML attributes
stringify-values? - to coerce non-nil, non-string, non-collection values to strings
remove-empty-attrs? - to remove any empty attribute maps
Transform an XML map as formatted by `clojure.xml/parse`, and transform it into normalized EDN. By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags. To change this behavior, an option map be provided with the following keys: preserve-keys? - to maintain the exact keyword structure provided by `clojure.xml/parse` preserve-attrs? - to maintain embedded XML attributes stringify-values? - to coerce non-nil, non-string, non-collection values to strings remove-empty-attrs? - to remove any empty attribute maps
(xml-seq->edn xml-seq)
(xml-seq->edn xml-seq {:keys [stringify-values? force-seq?] :as opts})
Transform an XML sequence as formatted by clojure.xml/parse
, and transform it into normalized EDN.
By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags.
To change this behavior, an option map be provided with the following keys:
preserve-keys? - to maintain the exact keyword structure provided by clojure.xml/parse
preserve-attrs? - to maintain embedded XML attributes
stringify-values? - to coerce non-nil, non-string, non-collection values to strings
remove-empty-attrs? - to remove any empty attribute maps
force-seq? - to coerce child XML nodes into a sequence of maps
Transform an XML sequence as formatted by `clojure.xml/parse`, and transform it into normalized EDN. By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags. To change this behavior, an option map be provided with the following keys: preserve-keys? - to maintain the exact keyword structure provided by `clojure.xml/parse` preserve-attrs? - to maintain embedded XML attributes stringify-values? - to coerce non-nil, non-string, non-collection values to strings remove-empty-attrs? - to remove any empty attribute maps force-seq? - to coerce child XML nodes into a sequence of maps
(xml-source->edn xml-source)
(xml-source->edn xml-source opts)
Parse an XML document source with clojure.xml/parse
and transform it into normalized EDN.
xml-source
may be an instance of java.io.InputStream or java.io.Reader
By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags.
To change this behavior, an option map may be provided with the following keys:
preserve-keys? - A boolean, that if set to true, maintains the exact keyword structure provided by clojure.xml/parse
preserve-attrs? - A boolean, that if set to true, maintains embedded XML attributes
stringify-values? - A boolean, that if set to true, coerces non-nil, non-string, non-collection values to strings
remove-empty-attrs? - A boolean, that if set to true, removes any empty attribute maps
force-seq? - A boolean, that if set to true, coerces child XML nodes into a sequence of maps
force-seq-for-paths - A sequence of key-path sequences that will be coerced into sequences.
It also surfaces the original options from clojure.data.xml/parse
include-node? - a subset of #{:element :characters :comment} default #{:element :characters}
location-info - pass false to skip generating location meta data
allocator - An instance of a XMLInputFactory/ALLOCATOR to allocate events
coalescing - A boolean, that if set to true, coalesces adjacent characters
namespace-aware - A boolean, that if set to false, disables XML 1.0 namespacing support
replacing-entity-references - A boolean, that if set to false, disables entity text replacement
supporting-external-entities - A boolean, that if set to true, will resolve external entities and parse them
validating - A boolean, that if set to true, will enable DTD validation
reporter - An instance of a XMLInputFactory/REPORTER to use in place of defaults
resolver - An instance of a XMLInputFactory/RESOLVER to use in place of defaults
support-dtd - A boolean, that if set to false, disables DTD support in parsers
skip-whitespace - A boolean, that if set to true, removes whitespace only elements
Parse an XML document source with `clojure.xml/parse` and transform it into normalized EDN. `xml-source` may be an instance of java.io.InputStream or java.io.Reader By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags. To change this behavior, an option map may be provided with the following keys: preserve-keys? - A boolean, that if set to true, maintains the exact keyword structure provided by `clojure.xml/parse` preserve-attrs? - A boolean, that if set to true, maintains embedded XML attributes stringify-values? - A boolean, that if set to true, coerces non-nil, non-string, non-collection values to strings remove-empty-attrs? - A boolean, that if set to true, removes any empty attribute maps force-seq? - A boolean, that if set to true, coerces child XML nodes into a sequence of maps force-seq-for-paths - A sequence of key-path sequences that will be coerced into sequences. It also surfaces the original options from `clojure.data.xml/parse` include-node? - a subset of #{:element :characters :comment} default #{:element :characters} location-info - pass false to skip generating location meta data allocator - An instance of a XMLInputFactory/ALLOCATOR to allocate events coalescing - A boolean, that if set to true, coalesces adjacent characters namespace-aware - A boolean, that if set to false, disables XML 1.0 namespacing support replacing-entity-references - A boolean, that if set to false, disables entity text replacement supporting-external-entities - A boolean, that if set to true, will resolve external entities and parse them validating - A boolean, that if set to true, will enable DTD validation reporter - An instance of a XMLInputFactory/REPORTER to use in place of defaults resolver - An instance of a XMLInputFactory/RESOLVER to use in place of defaults support-dtd - A boolean, that if set to false, disables DTD support in parsers skip-whitespace - A boolean, that if set to true, removes whitespace only elements
(xml-str->edn xml-str)
(xml-str->edn xml-str opts)
Parse an XML document with clojure.xml/parse-str
and transform it into normalized EDN.
By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags.
To change this behavior, an option map may be provided with the following keys:
preserve-keys? - A boolean, that if set to true, maintains the exact keyword structure provided by clojure.xml/parse
preserve-attrs? - A boolean, that if set to true, maintains embedded XML attributes
stringify-values? - A boolean, that if set to true, coerces non-nil, non-string, non-collection values to strings
remove-empty-attrs? - A boolean, that if set to true, removes any empty attribute maps
remove-newlines? - A boolean, that if set to true, removes any newline characters in xml-str
force-seq? - A boolean, that if set to true, coerces child XML nodes into a sequence of maps
force-seq-for-paths - A sequence of key-path sequences that will be coerced into sequences.
It also surfaces the original options from clojure.data.xml/parse-str
include-node? - A set containing elements of #{:element :characters :comment} default #{:element :characters}
location-info - A boolean, that if set to false, skips generating location meta data
allocator - An instance of a XMLInputFactory/ALLOCATOR to allocate events
coalescing - A boolean, that if set to true, coalesces adjacent characters
namespace-aware - A boolean, that if set to false, disables XML 1.0 namespacing support
replacing-entity-references - A boolean, that if set to false, disables entity text replacement
supporting-external-entities - A boolean, that if set to true, will resolve external entities and parse them
validating - A boolean, that if set to true, will enable DTD validation
reporter - An instance of a XMLInputFactory/REPORTER to use in place of defaults
resolver - An instance of a XMLInputFactory/RESOLVER to use in place of defaults
support-dtd - A boolean, that if set to false, disables DTD support in parsers
skip-whitespace - A boolean, that if set to true, removes whitespace only elements
Parse an XML document with `clojure.xml/parse-str` and transform it into normalized EDN. By default, this also mutates keys from XML_CASE to lisp-case and ignores XML attributes within tags. To change this behavior, an option map may be provided with the following keys: preserve-keys? - A boolean, that if set to true, maintains the exact keyword structure provided by `clojure.xml/parse` preserve-attrs? - A boolean, that if set to true, maintains embedded XML attributes stringify-values? - A boolean, that if set to true, coerces non-nil, non-string, non-collection values to strings remove-empty-attrs? - A boolean, that if set to true, removes any empty attribute maps remove-newlines? - A boolean, that if set to true, removes any newline characters in `xml-str` force-seq? - A boolean, that if set to true, coerces child XML nodes into a sequence of maps force-seq-for-paths - A sequence of key-path sequences that will be coerced into sequences. It also surfaces the original options from `clojure.data.xml/parse-str` include-node? - A set containing elements of #{:element :characters :comment} default #{:element :characters} location-info - A boolean, that if set to false, skips generating location meta data allocator - An instance of a XMLInputFactory/ALLOCATOR to allocate events coalescing - A boolean, that if set to true, coalesces adjacent characters namespace-aware - A boolean, that if set to false, disables XML 1.0 namespacing support replacing-entity-references - A boolean, that if set to false, disables entity text replacement supporting-external-entities - A boolean, that if set to true, will resolve external entities and parse them validating - A boolean, that if set to true, will enable DTD validation reporter - An instance of a XMLInputFactory/REPORTER to use in place of defaults resolver - An instance of a XMLInputFactory/RESOLVER to use in place of defaults support-dtd - A boolean, that if set to false, disables DTD support in parsers skip-whitespace - A boolean, that if set to true, removes whitespace only elements
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close