GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing clojure.github.io — clojure.data.xml - data.xml 0.2.1-SNAPSHOT API documentation API for clojure.data.xml - data.xml 0.2.1-SNAPSHOT (in development)by Chris HouserFull namespace name: clojure.data.xml OverviewProject home page is https://github.com/clojure/data.xml/
Functions to parse XML into lazy sequences and lazy trees and emit these as text. Public Variables and Functionsalias-urifunctionUsage: (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.
Source
elementfunctionUsage: (element tag)
(element tag attrs)
(element tag attrs & content)
Create an xml Element from content varargsSource element*functionUsage: (element* tag attrs content meta)
(element* tag attrs content)
Create an xml element from a content collection and optional metadataSource element-nssfunctionUsage: (element-nss {:keys [attrs], :as element})
Get xmlns environment from elementSource emitfunctionUsage: (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 useSource emit-strfunctionUsage: (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 useSource event-seqfunctionUsage: (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? subset of #{:element :characters :comment}, default #{:element :characters}
:location-info pass false to skip generating location meta data, default true
See https://docs.oracle.com/javase/8/docs/api/javax/xml/stream/XMLInputFactory.html
for documentation on xml options. These are the defaults:
{:allocator nil ; XMLInputFactory/ALLOCATOR
:coalescing true ; XMLInputFactory/IS_COALESCING
:namespace-aware true ; XMLInputFactory/IS_NAMESPACE_AWARE
:replacing-entity-references true ; XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES
:supporting-external-entities false ; XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES
:validating false ; XMLInputFactory/IS_VALIDATING
:reporter nil ; XMLInputFactory/REPORTER
:resolver nil ; XMLInputFactory/RESOLVER
:support-dtd true ; XMLInputFactory/SUPPORT_DTD
}
Source
indentfunctionUsage: (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.Source indent-strfunctionUsage: (indent-str e & opts) Emits the XML and indents the result. Writes the results to a String and returns itSource parsefunctionUsage: (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? subset of #{:element :characters :comment}, default #{:element :characters}
:location-info pass false to skip generating location meta data, default true
See https://docs.oracle.com/javase/8/docs/api/javax/xml/stream/XMLInputFactory.html
for documentation on xml options. These are the defaults:
{:allocator nil ; XMLInputFactory/ALLOCATOR
:coalescing true ; XMLInputFactory/IS_COALESCING
:namespace-aware true ; XMLInputFactory/IS_NAMESPACE_AWARE
:replacing-entity-references true ; XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES
:supporting-external-entities false ; XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES
:validating false ; XMLInputFactory/IS_VALIDATING
:reporter nil ; XMLInputFactory/REPORTER
:resolver nil ; XMLInputFactory/RESOLVER
:support-dtd true ; XMLInputFactory/SUPPORT_DTD
}
Source
parse-strfunctionUsage: (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? subset of #{:element :characters :comment}, default #{:element :characters}
:location-info pass false to skip generating location meta data, default true
See https://docs.oracle.com/javase/8/docs/api/javax/xml/stream/XMLInputFactory.html
for documentation on xml options. These are the defaults:
{:allocator nil ; XMLInputFactory/ALLOCATOR
:coalescing true ; XMLInputFactory/IS_COALESCING
:namespace-aware true ; XMLInputFactory/IS_NAMESPACE_AWARE
:replacing-entity-references true ; XMLInputFactory/IS_REPLACING_ENTITY_REFERENCES
:supporting-external-entities false ; XMLInputFactory/IS_SUPPORTING_EXTERNAL_ENTITIES
:validating false ; XMLInputFactory/IS_VALIDATING
:reporter nil ; XMLInputFactory/REPORTER
:resolver nil ; XMLInputFactory/RESOLVER
:support-dtd true ; XMLInputFactory/SUPPORT_DTD
}
Source
print-uri-file-command!functionUsage: (print-uri-file-command! uri) Shell command to create a dummy file for xmlns. Execute from a source root.Source sexps-as-fragmentfunctionUsage: (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.Source clojure.data.xml.eventData type for xml pull events TypesCDataEventrecordFields: [str] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map CharsEventrecordFields: [str] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map CommentEventrecordFields: [str] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map EmptyElementEventrecordFields: [tag attrs nss location-info] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map EndElementEventtypeFields: [] Protocols: Interfaces: QNameEventrecordFields: [qn] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map StartElementEventrecordFields: [tag attrs nss location-info] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map Public Variables and Functions->CDataEventfunctionUsage: (->CDataEvent str) Positional factory function for class clojure.data.xml.event.CDataEvent.Source ->CharsEventfunctionUsage: (->CharsEvent str) Positional factory function for class clojure.data.xml.event.CharsEvent.Source ->CommentEventfunctionUsage: (->CommentEvent str) Positional factory function for class clojure.data.xml.event.CommentEvent.Source ->EmptyElementEventfunctionUsage: (->EmptyElementEvent tag attrs nss location-info) Positional factory function for class clojure.data.xml.event.EmptyElementEvent.Source ->QNameEventfunctionUsage: (->QNameEvent qn) Positional factory function for class clojure.data.xml.event.QNameEvent.Source ->StartElementEventfunctionUsage: (->StartElementEvent tag attrs nss location-info) Positional factory function for class clojure.data.xml.event.StartElementEvent.Source element-nssfunctionUsage: (element-nss {:keys [attrs], :as element})
Get xmlns environment from elementSource map->CDataEventfunctionUsage: (map->CDataEvent m#) Factory function for class clojure.data.xml.event.CDataEvent, taking a map of keywords to field values.Source map->CharsEventfunctionUsage: (map->CharsEvent m#) Factory function for class clojure.data.xml.event.CharsEvent, taking a map of keywords to field values.Source map->CommentEventfunctionUsage: (map->CommentEvent m#) Factory function for class clojure.data.xml.event.CommentEvent, taking a map of keywords to field values.Source map->EmptyElementEventfunctionUsage: (map->EmptyElementEvent m#) Factory function for class clojure.data.xml.event.EmptyElementEvent, taking a map of keywords to field values.Source map->QNameEventfunctionUsage: (map->QNameEvent m#) Factory function for class clojure.data.xml.event.QNameEvent, taking a map of keywords to field values.Source map->StartElementEventfunctionUsage: (map->StartElementEvent m#) Factory function for class clojure.data.xml.event.StartElementEvent, taking a map of keywords to field values.Source clojure.data.xml.implShared private code for data.xml namespaces Public Variables and Functionscompile-ifmacroUsage: (compile-if exp then else) Evaluate `exp` and if it returns logical true and doesn't error, expand to `then`. Else expand to `else`. see clojure.core.reducersSource export-apimacroUsage: (export-api & names) This creates vars, that take their (local) name, value and metadata from another varSource extend-protocol-fnsmacroUsage: (extend-protocol-fns proto & types+mmaps) Helper to many types to a protocol with a method map, similar to extendSource static-casemacroUsage: (static-case val & cases) Variant of case where keys are evaluated at compile-timeSource clojure.data.xml.jvm.emitJVM implementation of the emitter details Public Variables and Functionswrite-documentfunctionUsage: (write-document swriter events opts) Writes the given event seq as XML text to writer. Options: :encoding <str> Character encoding to use :doctype <str> Document type (DOCTYPE) declaration to useSource clojure.data.xml.jvm.parsePublic Variables and Functionspull-seqfunctionUsage: (pull-seq sreader {:keys [include-node? location-info skip-whitespace namespace-aware], :as opts} ns-envs)
Creates a seq of events. The XMLStreamConstants/SPACE clause below doesn't seem to be triggered by the JDK StAX parser, but is by others. Leaving in to be more complete.Source clojure.data.xml.namePublic Variables and Functionsalias-urifunctionUsage: (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.
Source
gen-prefixfunctionUsage: (gen-prefix)
(gen-prefix n)
Generates an xml prefix. Zero-arity can only be called, when *gen-prefix-counter* is bound and will increment it.Source print-uri-file-command!functionUsage: (print-uri-file-command! uri) Shell command to create a dummy file for xmlns. Execute from a source root.Source separate-xmlnsfunctionUsage: (separate-xmlns attrs cont) Call cont with two args: attributes and xmlns attributesSource clojure.data.xml.nodeData types for xml nodes: Element, CData and Comment TypesCDatarecordFields: [content] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map CommentrecordFields: [content] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IKeywordLookup, clojure.lang.ILookup, clojure.lang.IObj, clojure.lang.IPersistentMap, java.io.Serializable, java.util.Map ElementtypeFields: [tag attrs content meta] Protocols: Interfaces: clojure.lang.IHashEq, clojure.lang.IObj, clojure.lang.IPersistentMap, clojure.lang.MapEquivalence, java.io.Serializable, java.lang.Iterable, java.util.Map ElementIteratortypeFields: [el fields] Protocols: Interfaces: java.util.Iterator Public Variables and Functions->CDatafunctionUsage: (->CData content) Positional factory function for class clojure.data.xml.node.CData.Source ->CommentfunctionUsage: (->Comment content) Positional factory function for class clojure.data.xml.node.Comment.Source ->ElementfunctionUsage: (->Element tag attrs content meta) Positional factory function for class clojure.data.xml.node.Element.Source ->ElementIteratorfunctionUsage: (->ElementIterator el fields) Positional factory function for class clojure.data.xml.node.ElementIterator.Source elementfunctionUsage: (element tag)
(element tag attrs)
(element tag attrs & content)
Create an xml Element from content varargsSource element*functionUsage: (element* tag attrs content meta)
(element* tag attrs content)
Create an xml element from a content collection and optional metadataSource map->CDatafunctionUsage: (map->CData m#) Factory function for class clojure.data.xml.node.CData, taking a map of keywords to field values.Source map->CommentfunctionUsage: (map->Comment m#) Factory function for class clojure.data.xml.node.Comment, taking a map of keywords to field values.Source clojure.data.xml.processPublic Variables and Functionsclojure.data.xml.protocolsProtocolsAsElementsProtocolKnown implementations: clojure.lang.IPersistentVector, clojure.lang.ISeq, clojure.lang.Keyword, java.lang.String, nil, Object as-elementsfunctionUsage: (as-elements expr) Return a seq of elements represented by an expression. AsQNameProtocolKnown implementations: clojure.lang.Keyword, java.lang.String, javax.xml.namespace.QName qname-localfunctionUsage: (qname-local qname) Get the name for this qname qname-urifunctionUsage: (qname-uri qname) Get the namespace uri for this qname AsXmlStringProtocolKnown implementations: array-of-bytes, clojure.lang.BigInt, clojure.lang.Ratio, java.lang.Boolean, java.lang.Byte, java.lang.Character, java.lang.Double, java.lang.Float, java.lang.Integer, java.lang.Long, java.lang.Short, java.lang.String, java.math.BigDecimal, java.math.BigInteger, java.net.URI, java.net.URL, java.time.Instant, java.util.Date, nil xml-strfunctionUsage: (xml-str node) Serialize atribute value or content node EventGenerationProtocolProtocol for generating new events based on element typeKnown implementations: array-of-bytes, clojure.data.xml.event.CDataEvent, clojure.data.xml.event.CDataEvent, clojure.data.xml.event.CharsEvent, clojure.data.xml.event.CharsEvent, clojure.data.xml.event.CommentEvent, clojure.data.xml.event.CommentEvent, clojure.data.xml.event.EmptyElementEvent, clojure.data.xml.event.EmptyElementEvent, clojure.data.xml.event.EndElementEvent, clojure.data.xml.event.EndElementEvent, clojure.data.xml.event.StartElementEvent, clojure.data.xml.event.StartElementEvent, clojure.data.xml.node.CData, clojure.data.xml.node.Comment, clojure.data.xml.node.Element, clojure.lang.IPersistentMap, clojure.lang.Keyword, clojure.lang.Sequential, java.lang.Boolean, java.lang.Number, java.lang.String, java.net.URI, java.net.URL, java.time.Instant, java.util.Date, javax.xml.namespace.QName, nil gen-eventfunctionUsage: (gen-event item) Function to generate an event for e. next-eventsfunctionUsage: (next-events item next-items) Returns the next set of events that should occur after e. next-events are the events that should be generated after this one is complete. clojure.data.xml.prxmlPublic Variables and Functionssexps-as-fragmentfunctionUsage: (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.Source clojure.data.xml.pu-mapProvides a bidirectional mapping for keeping track of prefix->uri mappings in xml namespaces. This has the semantics of a basic key -> multiple values map + two special features, both of which are dictated by the xml standard: - instead of a special dissoc, there is assoc to empty string or nil - there are two fixed, unique mappings: - "xml" <-> ["http://www.w3.org/2000/xmlns/"] - "xmlns" <-> ["http://www.w3.org/XML/1998/namespace"] Public Variables and Functionsreduce-difffunctionUsage: (reduce-diff f s {ppu :p->u} {pu :p->u})
A high-performance diffing operation, that reduces f over changed and removed prefixesSource clojure.data.xml.treePublic Variables and Functionsevent-treefunctionUsage: (event-tree events) Returns a lazy tree of Element objects for the given seq of Event objects. See source-seq and parse.Source flatten-elementsfunctionUsage: (flatten-elements elements) Flatten a collection of elements to an event seqSource seq-treefunctionUsage: (seq-tree parent exit? node coll) Takes a seq of events that logically represents
a tree by each event being one of: enter-sub-tree event,
exit-sub-tree event, or node event.
Returns a lazy sequence whose first element is a sequence of
sub-trees and whose remaining elements are events that are not
siblings or descendants of the initial event.
The given exit? function must return true for any exit-sub-tree
event. parent must be a function of two arguments: the first is an
event, the second a sequence of nodes or subtrees that are children
of the event. parent must return nil or false if the event is not
an enter-sub-tree event. Any other return value will become
a sub-tree of the output tree and should normally contain in some
way the children passed as the second arg. The node function is
called with a single event arg on every event that is neither parent
nor exit, and its return value will become a node of the output tree.
(seq-tree #(when (= %1 :<) (vector %2)) #{:>} str
[1 2 :< 3 :< 4 :> :> 5 :> 6])
;=> (("1" "2" [("3" [("4")])] "5") 6)
Source
Copyright 2007-2023 by Rich Hickey and the various contributors
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |