Cursor

An implementation of the isCursor trait.

This is the only provided cursor that builds on top of a parser (and not on top of another cursor), so it is part of virtually every parsing chain. All documented methods are implementations of the specifications dictated by isCursor.

Constructors

this
this(Args args)

Generic constructor; forwards its arguments to the parser constructor

Members

Aliases

CharacterType
alias CharacterType = P.CharacterType

The type of characters in the input, as returned by the underlying low level parser.

InputType
alias InputType = P.InputType

The type of input accepted by this parser, i.e., the one accepted by the underlying low level parser.

StringType
alias StringType = CharacterType[]

The type of sequences of CharacterType, as returned by this parser

Functions

atBeginning
bool atBeginning()

Returns whether the cursor is at the beginning of the document (i.e. whether no enter/next/exit has been performed successfully and thus the cursor points to the xml declaration)

attributes
auto attributes()

If the current node is an element, return its attributes as a range of triplets (prefix, name, value); if the current node is the document node, return the attributes of the xml declaration (encoding, version, ...); otherwise, returns an empty array.

content
StringType content()

Return the text content of a cdata section, a comment or a text node; in all other cases, returns the entire node without the name

documentEnd
bool documentEnd()

Returns whether the cursor is at the end of the document.

enter
bool enter()

Advances to the first child of the current node and returns true. If it returns false, the cursor is either on the same node (it wasn't an element start) or it is at the close tag of the element it was called on (it was a pair open/close tag without any content)

exit
void exit()

Advances to the end of the parent of the current node.

kind
XMLKind kind()

Returns the kind of the current node.

localName
StringType localName()

If the current node is an element, returns its local name (without namespace prefix); otherwise, returns the same result as name.

name
StringType name()

If the current node is an element or a doctype, returns its complete name; it it is a processing instruction, return its target; otherwise, returns an empty string;

next
bool next()

Advances to the next sibling of the current node. Returns whether it succeded. If it fails, either the document has ended or the only meaningful operation is exit.

prefix
StringType prefix()

If the current node is an element, returns its namespace prefix; otherwise, the result in unspecified;

save
auto save()
Undocumented in source. Be warned that the author may not have intended to support it.
setSource
void setSource(InputType input)

Initializes this cursor (and the underlying low level parser) with the given input.

wholeContent
StringType wholeContent()

Returns the entire text of the current node.

Properties

xmlDeclNotFound
bool xmlDeclNotFound [@property getter]

Returns true if XML declaration was not found.

Structs

AttributesRange
struct AttributesRange
Undocumented in source.

Variables

docType
StringType docType;
Undocumented in source.
encoding
StringType encoding;
Undocumented in source.
sysEntityLoader
StringType delegate(StringType path) sysEntityLoader;

Loads system entities if needed. If not used, then it can protect against certain system entity attacks at the cost of having this feature disabled.

Parameters

P

The parser.

processBadDocument

If set to Yes (default is No), then it'll ignore errors as long as it can still process the document. Otherwise it'll throw an appropriate exception if an error is encountered.

Meta