Liking cljdoc? Tell your friends :D

clojure.data.xml

clj

Functions to parse XML into lazy sequences and lazy trees and emit these as text.

Functions to parse XML into lazy sequences and lazy trees and
emit these as text.
raw docstring

aggregate-xmlnsclj

(aggregate-xmlns xml)

Put all occurring xmlns into the root

Put all occurring xmlns into the root
raw docstring

alias-uriclj

(alias-uri & {:as alias-nss})

Define a Clojure namespace aliases for xmlns uris.

This sets up the current namespace for reading qnames denoted with Clojure's ::alias/keywords reader feature.

Example

(alias-uri :D "DAV:") ; similar in effect to ;; (require '[xmlns.DAV%3A :as D]) ; but required namespace is auto-created ; henceforth, shorthand keywords can be used {:tag ::D/propfind} ; ::D/propfind will be expanded to :xmlns.DAV%3A/propfind ; in the current namespace by the reader

Clojurescript support

Currently, namespaces can't be auto-created in Clojurescript. Dummy files for aliased uris have to exist. Have a look at uri-file and print-uri-file-command! to create those.

Define a Clojure namespace aliases for xmlns uris.

This sets up the current namespace for reading qnames denoted with
Clojure's ::alias/keywords reader feature.


## Example
(alias-uri :D "DAV:")
                         ; similar in effect to
;; (require '[xmlns.DAV%3A :as D])
                         ; but required namespace is auto-created
                         ; henceforth, shorthand keywords can be used
{:tag ::D/propfind}
                         ; ::D/propfind will be expanded to :xmlns.DAV%3A/propfind
                         ; in the current namespace by the reader

## Clojurescript support
Currently, namespaces can't be auto-created in Clojurescript.
Dummy files for aliased uris have to exist. Have a look at `uri-file` and `print-uri-file-command!` to create those.
raw docstring

as-qnameclj/s≠

clj
(as-qname n)
cljs

cdataclj/s≠

clj
(cdata content)

Create a CData node

Create a CData node
cljs
raw docstring

elementclj/s≠

clj
(element tag)
(element tag attrs)
(element tag attrs & content)

Create an xml Element from content varargs

Create an xml Element from content varargs
cljs
raw docstring

element*clj/s≠

clj
(element* tag attrs content)
(element* tag attrs content meta)

Create an xml element from a content collection and optional metadata

Create an xml element from a content collection and optional metadata
cljs
raw docstring

element-datacljs


element-nodecljs


element-nssclj

(element-nss {:keys [attrs] :as element})

Get xmlns environment from element

Get xmlns environment from element
raw docstring

element?clj/s≠

clj
(element? el)
cljs

emitclj

(emit e writer & {:as opts})

Prints the given Element tree as XML text to stream. Options: :encoding <str> Character encoding to use :doctype <str> Document type (DOCTYPE) declaration to use

Prints the given Element tree as XML text to stream.
Options:
 :encoding <str>          Character encoding to use
 :doctype  <str>          Document type (DOCTYPE) declaration to use
raw docstring

emit-strclj/s≠

clj
(emit-str e & opts)

Emits the Element to String and returns it. Options: :encoding <str> Character encoding to use :doctype <str> Document type (DOCTYPE) declaration to use

Emits the Element to String and returns it.
Options:
 :encoding <str>          Character encoding to use
 :doctype  <str>          Document type (DOCTYPE) declaration to use
cljs
(emit-str e & {:keys []})

Use XMLSerializer to render an xml string

Use XMLSerializer to render an xml string
raw docstring

event-seqclj

(event-seq source
           {:keys [include-node? location-info coalescing
                   supporting-external-entities allocator namespace-aware
                   replacing-entity-references validating reporter resolver
                   support-dtd]
            :or {include-node? #{:characters :element}
                 location-info true
                 coalescing true
                 supporting-external-entities false}})

Parses an XML input source into a lazy sequence of pull events.

Input source can be a java.io.InputStream or java.io.Reader

Options:

:include-node? can be a subset of #{:element :characters :comment} default #{:element :characters} :location-info pass false to skip generating location meta data

See http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html for documentation on options:

{:allocator XMLInputFactory/ALLOCATOR :coalescing XMLInputFactory/IS_COALESCING :namespace-aware XMLInputFactory/IS_NAMESPACE_AWARE :replacing-entity-references XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES :supporting-external-entities XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES :validating XMLInputFactory/IS_VALIDATING :reporter XMLInputFactory/REPORTER :resolver XMLInputFactory/RESOLVER :support-dtd XMLInputFactory/SUPPORT_DTD}

Parses an XML input source into a lazy sequence of pull events.

Input source can be a java.io.InputStream or java.io.Reader

Options:

  :include-node? can be a subset of #{:element :characters :comment} default #{:element :characters}
  :location-info pass false to skip generating location meta data

See http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html
for documentation on options:

  {:allocator                      XMLInputFactory/ALLOCATOR
   :coalescing                     XMLInputFactory/IS_COALESCING
   :namespace-aware                XMLInputFactory/IS_NAMESPACE_AWARE
   :replacing-entity-references    XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES
   :supporting-external-entities   XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES
   :validating                     XMLInputFactory/IS_VALIDATING
   :reporter                       XMLInputFactory/REPORTER
   :resolver                       XMLInputFactory/RESOLVER
   :support-dtd                    XMLInputFactory/SUPPORT_DTD}
raw docstring

extend-dom-as-data!cljs


find-xmlnsclj

(find-xmlns xml)

Find all xmlns occuring in a root

Find all xmlns occuring in a root
raw docstring

indentclj

(indent e writer & opts)

Emits the XML and indents the result. WARNING: this is slow it will emit the XML and read it in again to indent it. Intended for debugging/testing only.

Emits the XML and indents the result.  WARNING: this is slow
it will emit the XML and read it in again to indent it.  Intended for
debugging/testing only.
raw docstring

indent-strclj

(indent-str e & opts)

Emits the XML and indents the result. Writes the results to a String and returns it

Emits the XML and indents the result.  Writes the results to a String and returns it
raw docstring

parseclj

(parse source
       &
       {:keys [include-node? location-info coalescing
               supporting-external-entities allocator namespace-aware
               replacing-entity-references validating reporter resolver
               support-dtd]
        :or {include-node? #{:characters :element}
             location-info true
             coalescing true
             supporting-external-entities false}})

Parses an XML input source into a a tree of Element records. The element tree is realized lazily, so huge XML files can be streamed through a depth-first tree walk.

Input source can be a java.io.InputStream or java.io.Reader

Options:

:include-node? can be a subset of #{:element :characters :comment} default #{:element :characters} :location-info pass false to skip generating location meta data

See http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html for documentation on options:

{:allocator XMLInputFactory/ALLOCATOR :coalescing XMLInputFactory/IS_COALESCING :namespace-aware XMLInputFactory/IS_NAMESPACE_AWARE :replacing-entity-references XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES :supporting-external-entities XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES :validating XMLInputFactory/IS_VALIDATING :reporter XMLInputFactory/REPORTER :resolver XMLInputFactory/RESOLVER :support-dtd XMLInputFactory/SUPPORT_DTD}

Parses an XML input source into a a tree of Element records.
The element tree is realized lazily, so huge XML files can be streamed through a depth-first tree walk.

Input source can be a java.io.InputStream or java.io.Reader

Options:

  :include-node? can be a subset of #{:element :characters :comment} default #{:element :characters}
  :location-info pass false to skip generating location meta data

See http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html
for documentation on options:

  {:allocator                      XMLInputFactory/ALLOCATOR
   :coalescing                     XMLInputFactory/IS_COALESCING
   :namespace-aware                XMLInputFactory/IS_NAMESPACE_AWARE
   :replacing-entity-references    XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES
   :supporting-external-entities   XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES
   :validating                     XMLInputFactory/IS_VALIDATING
   :reporter                       XMLInputFactory/REPORTER
   :resolver                       XMLInputFactory/RESOLVER
   :support-dtd                    XMLInputFactory/SUPPORT_DTD}
raw docstring

parse-qnameclj/s


parse-strclj/s≠

clj
(parse-str string
           &
           {:keys [include-node? location-info coalescing
                   supporting-external-entities allocator namespace-aware
                   replacing-entity-references validating reporter resolver
                   support-dtd]
            :or {include-node? #{:characters :element}
                 location-info true
                 coalescing true
                 supporting-external-entities false}})

Parses an XML String into a a tree of Element records.

Options:

:include-node? can be a subset of #{:element :characters :comment} default #{:element :characters} :location-info pass false to skip generating location meta data

See http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html for documentation on options:

{:allocator XMLInputFactory/ALLOCATOR :coalescing XMLInputFactory/IS_COALESCING :namespace-aware XMLInputFactory/IS_NAMESPACE_AWARE :replacing-entity-references XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES :supporting-external-entities XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES :validating XMLInputFactory/IS_VALIDATING :reporter XMLInputFactory/REPORTER :resolver XMLInputFactory/RESOLVER :support-dtd XMLInputFactory/SUPPORT_DTD}

Parses an XML String into a a tree of Element records.

Options:

  :include-node? can be a subset of #{:element :characters :comment} default #{:element :characters}
  :location-info pass false to skip generating location meta data

See http://docs.oracle.com/javase/6/docs/api/javax/xml/stream/XMLInputFactory.html
for documentation on options:

  {:allocator                      XMLInputFactory/ALLOCATOR
   :coalescing                     XMLInputFactory/IS_COALESCING
   :namespace-aware                XMLInputFactory/IS_NAMESPACE_AWARE
   :replacing-entity-references    XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES
   :supporting-external-entities   XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES
   :validating                     XMLInputFactory/IS_VALIDATING
   :reporter                       XMLInputFactory/REPORTER
   :resolver                       XMLInputFactory/RESOLVER
   :support-dtd                    XMLInputFactory/SUPPORT_DTD}
cljs
(parse-str s
           &
           {:keys [content-type on-error raw]
            :or {content-type "text/xml"
                 on-error (fn* [p1__1205#]
                               (throw (ex-info "XML parser error"
                                               {:doc p1__1205# :input s})))}})

Use DOMParser to parse xml string

Use DOMParser to parse xml string
raw docstring

(print-uri-file-command! uri)

Shell command to create a dummy file for xmlns. Execute from a source root.

Shell command to create a dummy file for xmlns. Execute from a source root.
raw docstring

qnameclj/s≠

clj
(qname local)
(qname uri local)
(qname uri local prefix)
cljs

qname-localclj/s≠

clj
(qname-local v)

Get the name for this qname

Get the name for this qname
cljs
raw docstring

qname-uriclj/s≠

clj
(qname-uri v)

Get the namespace uri for this qname

Get the namespace uri for this qname
cljs
raw docstring

sexp-as-elementclj

(sexp-as-element sexp)

Convert a single sexp into an Element

Convert a single sexp into an Element
raw docstring

sexps-as-fragmentclj

(sexps-as-fragment)
(sexps-as-fragment sexp)
(sexps-as-fragment sexp & sexps)

Convert a compact prxml/hiccup-style data structure into the more formal tag/attrs/content format. A seq of elements will be returned, which may not be suitable for immediate use as there is no root element. See also sexp-as-element.

The format is [:tag-name attr-map? content*]. Each vector opens a new tag; seqs do not open new tags, and are just used for inserting groups of elements into the parent tag. A bare keyword not in a vector creates an empty element.

To provide XML conversion for your own data types, extend the AsElements protocol to them.

Convert a compact prxml/hiccup-style data structure into the more formal
tag/attrs/content format. A seq of elements will be returned, which may
not be suitable for immediate use as there is no root element. See also
sexp-as-element.

The format is [:tag-name attr-map? content*]. Each vector opens a new tag;
seqs do not open new tags, and are just used for inserting groups of elements
into the parent tag. A bare keyword not in a vector creates an empty element.

To provide XML conversion for your own data types, extend the AsElements
protocol to them.
raw docstring

symbol-uriclj/s≠

clj
(symbol-uri ss)
cljs

uri-fileclj

(uri-file uri)

Dummy file name for :require'ing xmlns uri

Dummy file name for :require'ing xmlns uri
raw docstring

uri-symbolclj/s≠

clj
(uri-symbol uri)
cljs

xml-commentclj/s≠

clj
(xml-comment content)

Create a Comment node

Create a Comment node
cljs
raw docstring

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

× close