Liking cljdoc? Tell your friends :D

clj-xml.core

A bunch of utility functions for xml documents.

A bunch of utility functions for xml documents.
raw docstring

edn->xmlclj

(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
sourceraw docstring

edn->xml-strclj

(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
sourceraw docstring

edn->xml-streamclj

(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
sourceraw docstring

edn-map->xmlclj

(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
sourceraw docstring

edn-seq->xmlclj

(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
sourceraw docstring

every-childclj

An alias for the ::every namespaced keyword.

Used to ensure selective paths in the returned XML are coerced to sequences. This option forces all child nodes to be coerced into a sequence of maps.

An alias for the ::every namespaced keyword.

Used to ensure selective paths in the returned XML are coerced to sequences.
This option forces all child nodes to be coerced into a sequence of maps.
sourceraw docstring

first-childclj

An alias for the ::first namespaced keyword.

Used to ensure selective paths in the returned XML are coerced to sequences. This option forces only the first child node to be coerced into a sequence of maps.

An alias for the ::first namespaced keyword.

Used to ensure selective paths in the returned XML are coerced to sequences.
This option forces only the first child node to be coerced into a sequence of maps.
sourceraw docstring

force-xml-seq-at-pathclj

(force-xml-seq-at-path xml-edn [xml-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:

  • ::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
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:
   - ::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
sourceraw docstring

force-xml-seq-at-pathsclj

(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:

  • ::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
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:
   - ::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
sourceraw docstring

last-childclj

An alias for the ::last namespaced keyword.

Used to ensure selective paths in the returned XML are coerced to sequences. This option forces only the last child node to be coerced into a sequence of maps.

An alias for the ::last namespaced keyword.

Used to ensure selective paths in the returned XML are coerced to sequences.
This option forces only the last child node to be coerced into a sequence of maps.
sourceraw docstring

xml->ednclj

(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
sourceraw docstring

xml->edn'clj

(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
sourceraw docstring

xml-map->ednclj

(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
sourceraw docstring

xml-seq->ednclj

(xml-seq->edn xml-sequence)
(xml-seq->edn xml-sequence {: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
sourceraw docstring

xml-source->ednclj

(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
sourceraw docstring

xml-str->ednclj

(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
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close