Liking cljdoc? Tell your friends :D

clj-vtd-xml.core

This is a Clojure wrapper around the Java VTD-XML parser, which provides very fast XML parsing.

This is a Clojure wrapper around the Java VTD-XML parser, which provides
very fast XML parsing.
raw docstring

all-matchesclj

(all-matches navigator xpath)
(all-matches navigator xpath ns-hash)

Returns a lazy seq of the content of all nodes matching the specified XPATH. The only nodes that will be searched are the node to which the navigator is currently pointing and its descendants. Use a relative XPATH expression!

Returns a lazy seq of the content of all nodes matching the specified XPATH.
The only nodes that will be searched are the node to which the navigator
is currently pointing and its descendants. Use a relative XPATH expression!
sourceraw docstring

attr-nameclj

(attr-name xpath)

Returns the attribute name from an xpath expression. This is the text after the @ sign. Param xpath is a string. Returns the entire string if there is no @ sign, or if there's nothing after the @ sign. For example, if xpath is '/company/address/@city', this will return 'city'.

Returns the attribute name from an xpath expression. This is the text after
the @ sign. Param xpath is a string. Returns the entire string if there is
no @ sign, or if there's nothing after the @ sign. For example, if xpath
is '/company/address/@city', this will return 'city'.
sourceraw docstring

attribute-textclj

(attribute-text navigator attribute-name)

Returns the text content of the attribute that the navigator is currently pointing to. Assumes that navigator is not nil, and is pointing to an element.

Returns the text content of the attribute that the navigator is currently
pointing to. Assumes that navigator is not nil, and is pointing to an
element.
sourceraw docstring

attribute?clj

(attribute? navigator)

Returns true if the navigator is pointing to an attribute.

Returns true if the navigator is pointing to an attribute.
sourceraw docstring

element-textclj

(element-text navigator)

Returns the text content of the element that the navigator is currently pointing to. Assumes that navigator is not nil, and is pointing to an element.

Returns the text content of the element that the navigator is currently
pointing to. Assumes that navigator is not nil, and is pointing to an
element.
sourceraw docstring

element?clj

(element? navigator)

Returns true if the navigator is pointing to an element.

Returns true if the navigator is pointing to an element.
sourceraw docstring

find-indexesclj

(find-indexes navigator xpath)
(find-indexes navigator xpath ns-hash)

Returns a lazy seq of VTDNav objects, one for each element in the XML doc that matches the specified xpath. VTDNav objects are merely pointers to positions within the byte stream. You can pass each of these objects to the content function to extract the text content, or pass them to the the raw-xml function to retrieve the literal XML string.

Returns a lazy seq of VTDNav objects, one for each element in the XML
doc that matches the specified xpath. VTDNav objects are merely pointers
to positions within the byte stream. You can pass each of these objects
to the content function to extract the text content, or pass them to the
the raw-xml function to retrieve the literal XML string.
sourceraw docstring

first-matchclj

(first-match navigator xpath)
(first-match navigator xpath ns-hash)

Returns the text content of the first node within the navigator that matches the specified XPATH expression. The only nodes that will be searched are the node to which the navigator is currently pointing and its descendants. Use a relative XPATH expression!

Returns the text content of the first node within the navigator that
matches the specified XPATH expression. The only nodes that will be
searched are the node to which the navigator is currently pointing and
its descendants. Use a relative XPATH expression!
sourceraw docstring

get-hashclj

(get-hash navigator xpath)
(get-hash navigator xpath ns-hash)

Converts the XML element(s) at the specified xpath to a seq of hashes, using a fast SAX parser. The seq will contain one hash for each element that matched the xpath expression.

The xpath expression should return an element, not an attribute, because the SAX parser is expecting XML markup.

If your xpath leads to an attribute, use (all-matches nav xpath) to retrieve the value.

Some text values within the hash may have leading, trailing, and embedded spaces. You can call (normalize-text str) to get rid of these.

This function uses clojure.xml/parse, so an XML node like this:

<Employee role="Elected Member"> <Name>John McCain</Name> </Employee>

Will yield a hash structure like this:

{:tag :Employee, :attrs {:role "Elected Member"}, :content [{:tag :Name, :attrs nil, :content ["John McCain"]}]}

Converts the XML element(s) at the specified xpath to a seq of hashes,
using a fast SAX parser. The seq will contain one hash for each element
that matched the xpath expression.

The xpath expression should return an element, not an attribute,
because the SAX parser is expecting XML markup.

If your xpath leads to an attribute, use (all-matches nav xpath) to
retrieve the value.

Some text values within the hash may have leading, trailing, and embedded
spaces. You can call (normalize-text str) to get rid of these.

This function uses clojure.xml/parse, so an XML node like this:

<Employee role="Elected Member">
  <Name>John McCain</Name>
</Employee>

Will yield a hash structure like this:

{:tag   :Employee,
 :attrs {:role "Elected Member"},
 :content [{:tag :Name,
            :attrs nil,
            :content ["John McCain"]}]}
sourceraw docstring

get-xmlclj

(get-xml navigator xpath)
(get-xml navigator xpath ns-hash)

Returns a lazy seq of the literal XML of all nodes matching the specified xpath. Each item in the seq is a string. Param nav is a VTDNav object, which you can create with the navigator function.

Returns a lazy seq of the literal XML of all nodes matching the specified
xpath. Each item in the seq is a string. Param nav is a VTDNav object,
which you can create with the navigator function.
sourceraw docstring

is-within?clj

(is-within? nav1 nav2)
(is-within? navigator start end)

Returns true if the element that nav2 points to is inside of the element that nav1 is pointing to.

Returns true if the navigator is pointing to an element whose start position is between start and end.

Returns true if the element that nav2 points to is inside of the element
that nav1 is pointing to.

Returns true if the navigator is pointing to an element whose start
position is between start and end.
sourceraw docstring

(navigator xml-string namespace-aware)

Given an XML string, returns a VTDNav object. Param namespace-aware is a boolean indicating whether the navigator should take XML namespaces into account.

Given an XML string, returns a VTDNav object. Param namespace-aware
is a boolean indicating whether the navigator should take XML namespaces
into account.
sourceraw docstring

node-nameclj

(node-name navigator)

Returns the name of the element the navigator is currently pointing to.

Returns the name of the element the navigator is currently pointing to.
sourceraw docstring

normalize-textclj

(normalize-text string)

Removes leading and trailing spaces. Collapses multiple spaces within the string to a single space.

Removes leading and trailing spaces. Collapses multiple spaces within
the string to a single space.
sourceraw docstring

positionclj

(position navigator)

Returns a hash with keys :offset and :length describing where in the byte stream the current element begins and how long it is.

Returns a hash with keys :offset and :length describing where in the byte
stream the current element begins and how long it is.
sourceraw docstring

raw-xml-streamclj

(raw-xml-stream navigator)

Returns a ByteArrayInputStream of the xml element at the current navigator index. This means an XML snippet with start tag, end tag, and everything in between. This stream is suitable for feeding to a SAX reader, or to the get-hash function. Note that if your xpath specifies an attribute, you will get the entire element that is the parent of that attribute.

Returns a ByteArrayInputStream of the xml element at the current navigator
index. This means an XML snippet with start tag, end tag, and everything
in between. This stream is suitable for feeding to a SAX reader, or to the
get-hash function. Note that if your xpath specifies an attribute, you will
get the entire element that is the parent of that attribute.
sourceraw docstring

raw-xml-stringclj

(raw-xml-string navigator)

Returns the raw xml element at the current navigator index. This means an XML snippet with start tag, end tag, and everything in between. Even if your xpath specified an attribute, you will get XML for the entire element that contains that attribute.

Returns the raw xml element at the current navigator index. This means
an XML snippet with start tag, end tag, and everything in between. Even if
your xpath specified an attribute, you will get XML for the entire element
that contains that attribute.
sourceraw docstring

re-spacesclj

source

split-charclj

source

to-first-child!clj

(to-first-child! navigator)
(to-first-child! navigator element-name)

Moves the VTDNav object's cursor to the first child of whatever element it's currently pointing to. This changes the navigator's internal pointer!

Moves the VTDNav object's cursor to the first child of whatever element
it's currently pointing to. This changes the navigator's internal pointer!
sourceraw docstring

to-last-child!clj

(to-last-child! navigator)
(to-last-child! navigator element-name)

Moves the VTDNav object's cursor to the last child of whatever element it's currently pointing to. This changes the navigator's internal pointer!

Moves the VTDNav object's cursor to the last child of whatever element
it's currently pointing to. This changes the navigator's internal pointer!
sourceraw docstring

to-next-sibling!clj

(to-next-sibling! navigator)
(to-next-sibling! navigator element-name)

Moves the VTDNav object's cursor to the next sibling of whatever element it's currently pointing to. This changes the navigator's internal pointer!

Moves the VTDNav object's cursor to the next sibling of whatever element
it's currently pointing to. This changes the navigator's internal pointer!
sourceraw docstring

to-parent!clj

(to-parent! navigator)

Moves the VTDNav object's cursor to the parent of whatever element it's currently pointing to. This changes the navigator's internal pointer!

Moves the VTDNav object's cursor to the parent of whatever element it's
currently pointing to. This changes the navigator's internal pointer!
sourceraw docstring

to-prev-sibling!clj

(to-prev-sibling! navigator)
(to-prev-sibling! navigator element-name)

Moves the VTDNav object's cursor to the previous sibling of whatever element it's currently pointing to. This changes the navigator's internal pointer!

Moves the VTDNav object's cursor to the previous sibling of whatever
element it's currently pointing to. This changes the navigator's internal
pointer!
sourceraw docstring

token-typeclj

(token-type navigator)

Returns the type of token at the current navigator index. This is an integer which you can test against the following enumeration.

0 com.ximpleware.VTDNav/TOKEN_STARTING_TAG 1 com.ximpleware.VTDNav/TOKEN_ENDING_TAG 2 com.ximpleware.VTDNav/TOKEN_ATTR_NAME 3 com.ximpleware.VTDNav/TOKEN_ATTR_NS 4 com.ximpleware.VTDNav/TOKEN_ATTR_VAL 5 com.ximpleware.VTDNav/TOKEN_CHARACTER_DATA 6 com.ximpleware.VTDNav/TOKEN_COMMENT 7 com.ximpleware.VTDNav/TOKEN_PI_NAME 8 com.ximpleware.VTDNav/TOKEN_PI_VAL 9 com.ximpleware.VTDNav/TOKEN_DEC_ATTR_NAME 10 com.ximpleware.VTDNav/TOKEN_DEC_ATTR_VAL 11 com.ximpleware.VTDNav/TOKEN_CDATA_VAL 12 com.ximpleware.VTDNav/TOKEN_DTD_VAL 13 com.ximpleware.VTDNav/TOKEN_DOCUMENT

Returns the type of token at the current navigator index. This is an integer
which you can test against the following enumeration.

0   com.ximpleware.VTDNav/TOKEN_STARTING_TAG
1   com.ximpleware.VTDNav/TOKEN_ENDING_TAG
2   com.ximpleware.VTDNav/TOKEN_ATTR_NAME
3   com.ximpleware.VTDNav/TOKEN_ATTR_NS
4   com.ximpleware.VTDNav/TOKEN_ATTR_VAL
5   com.ximpleware.VTDNav/TOKEN_CHARACTER_DATA
6   com.ximpleware.VTDNav/TOKEN_COMMENT
7   com.ximpleware.VTDNav/TOKEN_PI_NAME
8   com.ximpleware.VTDNav/TOKEN_PI_VAL
9   com.ximpleware.VTDNav/TOKEN_DEC_ATTR_NAME
10  com.ximpleware.VTDNav/TOKEN_DEC_ATTR_VAL
11  com.ximpleware.VTDNav/TOKEN_CDATA_VAL
12  com.ximpleware.VTDNav/TOKEN_DTD_VAL
13  com.ximpleware.VTDNav/TOKEN_DOCUMENT
sourceraw docstring

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

× close