juno.xml.streaming Module

Provides a streaming API for reading and writing XML data.

Licence
See licence.txt for use and distribution terms.

class XmlReaderSettings;

Specifies features to support on the XmlReader object.

this();

Initializes a new instance.

void reset();

Resets the members to their default values.

void conformanceLevel(XmlConformanceLevel value);
XmlConformanceLevel conformanceLevel();

Gets or sets the level of conformance with which the XmlReader will comply.

void prohibitDtd(bool value);
bool prohibitDtd();

Gets or sets a value indicating whether to prohibit document type definition (DTD) processing.

class XmlParserContext;

Provides context information required by the XmlReader to parse an XML fragment.

this(string baseURI, Encoding encoding = null);

Initializes a new instance.

Parameters
string baseURI
The base URI for the XML fragment.
Encoding encoding
An Encoding object indicating the encoding setting.

final void baseURI(char[] value);
final char[] baseURI();

Gets or sets the base URI.

final void encoding(Encoding value);
final Encoding encoding();

Gets or sets the encoding setting.

abstract class XmlReader;

Represents a reader that provides forward-only access to XML data.

static XmlReader create(char[] inputUri, XmlReaderSettings settings = cast(XmlReaderSettings)null, XmlParserContext context = cast(XmlParserContext)null);

Creates a new XmlReader instance with the specified URI, XmlReaderSettings and XmlParserContext objects.

static XmlReader create(Stream input, XmlReaderSettings settings = cast(XmlReaderSettings)null, XmlParserContext context = cast(XmlParserContext)null);

Creates a new XmlReader instance with the specified stream, XmlReaderSettings and XmlParserContext objects.

static XmlReader create(Stream input, XmlReaderSettings settings, char[] baseUri);

Creates a new XmlReader instance with the specified stream, XmlReaderSettings and base URI.

abstract void close();

Closes the reader.

abstract bool read();

Reads the next node from the stream.

Returns
true if the next node was read successfully; false if there are no more nodes to read.

void readStartElement(char[] localName, char[] ns);
void readStartElement(char[] name);
void readStartElement();

Checks that the current node is an element and advances the reader to the next node.

Parameters
char[] localName
The local name of the element.
name
The qualified name of the element.
char[] ns
The namespace URI of the element.

void readEndElement();

Checks that the current content node is an end tag and advances the reader to the next node.

char[] readElementString(char[] localName, char[] ns);
char[] readElementString(char[] name);
char[] readElementString();

Reads a text-only element.

Parameters
char[] localName
The local name of the element.
name
The qualified name of the element.
char[] ns
The namespace URI of the element.

bool readToDescendant(char[] localName, char[] namespaceURI);
bool readToDescendant(char[] name);

Advances the XmlReader to the next descendant element. localName = The local name of the element. name = The qualified name of the element. namespaceURI = The namespace URI of the element.

bool readToFollowing(char[] localName, char[] namespaceURI);
bool readToFollowing(char[] name);

Reads until the named element is found. localName = The local name of the element. name = The qualified name of the element. namespaceURI = The namespace URI of the element.

bool readToNextSibling(char[] localName, char[] namespaceURI);
bool readToNextSibling(char[] name);

Advances the XmlReader to the next sibling element. localName = The local name of the element. name = The qualified name of the element. namespaceURI = The namespace URI of the element.

XmlNodeType moveToContent();

If the current node is not a content node, the reader skips ahead to the next content node or end of file.

char[] readString();

Reads the contents of an element or text node.

Returns
The contents of an element.

void skip();

Skips the children of the current node.

abstract bool moveToFirstAttribute();

Moves to the first attribute.

Returns
true if an attribute exists; otherwise, false.

abstract bool moveToNextAttribute();

Moves to the next attribute.

Returns
true if there is a next attribute; otherwise, false.

abstract bool moveToAttribute(char[] localName, char[] namespaceURI);
abstract bool moveToAttribute(char[] name);

Moves to the specified attribute.

Parameters
char[] localName
The local name of the element.
name
The qualified name of the element.
char[] namespaceURI
The namespace URI of the element.

Returns
true if the attribute is found; otherwise, false.

abstract bool moveToElement();

Moves to the element that contains the current attribute node.

Returns
true if the reader is positioned on an attribute; otherwise, false.

abstract char[] getAttribute(char[] localName, char[] namespaceURI);
abstract char[] getAttribute(char[] name);

Gets the value of an attribute.

Parameters
char[] localName
The local name of the element.
name
The qualified name of the element.
char[] namespaceURI
The namespace URI of the element.

Returns
The value of the specified attribute.

abstract XmlReadState readState();

Gets the state of the reader.

abstract int depth();

Gets the depth of the current node in the XML document.

abstract bool isEOF();

Gets a value indicating whether the reader is positioned at the end of the stream.

abstract bool isEmptyElement();

Gets a value indicating whether the current node is an empty element.

bool isDefault();

Gets a value indicating whether the current node is an attribute generated from the default value defined in the DTD or schema.

abstract XmlNodeType nodeType();

Gets the type of the current node.

abstract char[] baseURI();

Gets the base URI of the current node.

abstract char[] name();

Gets the qualified name of the current node.

abstract char[] prefix();

Gets the namespace prefix of the current node.

abstract char[] localName();

Gets the local name of the current node.

abstract char[] namespaceURI();

Gets the namespace URI of the current node.

abstract bool hasValue();

Gets a value indicating whether the current node has a value.

abstract char[] value();

Gets the text value of the current node.

bool hasAttributes();

Gets a value indicating whether the current node has any attributes.

abstract int attributeCount();

Gets the number of attributes on the current node.

abstract int lineNumber();



abstract int linePosition();



char[] opIndex(char[] localName, char[] namespaceURI);
char[] opIndex(char[] name);

Gets the value of the attribute.

Parameters
char[] localName
The local name of the element.
name
The qualified name of the element.
char[] namespaceURI
The namespace URI of the element.

Returns
The value of the specified attribute.

class XmlWriterSettings;

Specifies features to support on the XmlWriter object.

this();

Initialized a new instance.

void reset();

Resets the members to their default values.

void encoding(Encoding value);
Encoding encoding();

Gets or sets the type of text encoding to use.

void conformanceLevel(XmlConformanceLevel value);
XmlConformanceLevel conformanceLevel();

Gets or sets the level of conformance the XmlReader complies with.

void indent(bool value);
bool indent();

Gets or sets a value indicating whether to indent elements.

bool omitXmlDeclaration();
void omitXmlDeclaration(bool value);

Gets or sets a value indicating whether to write an XML declaration.

abstract class XmlWriter;

Represents a writer that provides a forward-only means of generating streams or files containing XML data.

static XmlWriter create(char[] outputFileName, XmlWriterSettings settings = cast(XmlWriterSettings)null);

Creates a new instance.

Parameters
char[] outputFileName
The file to write to.
XmlWriterSettings settings
The XmlWriterSettings object used to configure the new instance.

Returns
A new XmlWriter instance.

static XmlWriter create(Stream output, XmlWriterSettings settings = cast(XmlWriterSettings)null);

Creates a new instance.

Parameters
Stream output
The stream to write to.
XmlWriterSettings settings
The XmlWriterSettings object used to configure the new instance.

Returns
A new XmlWriter instance.

abstract void close();

Closes this stream.

abstract void writeAttributes(XmlReader reader, bool defattr);

Writes out all the attributes.

abstract void writeAttributeString(char[] prefix, char[] localname, char[] ns, char[] value);
final void writeAttributeString(char[] localName, char[] ns, char[] value);
final void writeAttributeString(char[] localName, char[] value);

Writes an attribute.

abstract void writeCData(char[] text);

Writes out a <![CDATA[...]]> block containing the specified text.

abstract void writeCharEntity(char ch);

Writes a character entity for the specified character value.

abstract void writeChars(char[] buffer, int index, int count);

Writes the text contained in the specified buffer.

abstract void writeComment(char[] text);

Writes out a <!--...--> containing the specified text.

abstract void writeDocType(char[] name, char[] pubid, char[] sysid, char[] subset);

Writes the DOCTYPE declaration with the specified name and optional attributes.

abstract void writeElementString(char[] prefix, char[] localName, char[] ns, char[] value);
final void writeElementString(char[] localName, char[] ns, char[] value);
final void writeElementString(char[] localName, char[] value);

Writes an element containing the specified value.

abstract void writeEndDocument();

Closes any open elements or attributes.

abstract void writeEndElement();

Closes one element and pops the corresponding namespace scope.

abstract void writeEntityRef(char[] name);

Writes out an entity reference as &name;.

abstract void writeFullEndElement();

Closes one element and pops the corresponding namespace scope.

abstract void writeName(char[] name);

Writes out the specified name.

abstract void writeNmToken(char[] name);

Writes out the specified name.

abstract void writeNode(XmlReader reader, bool defattr);

Copies everything from the source reader to the current writer.

Parameters
XmlReader reader
The XmlReader to read from.
bool defattr
true to copy the default attributes from reader; otherwise, false.

abstract void writeProcessingInstruction(char[] name, char[] text);

Writes out a processing instruction as follows: <?name text?>.

abstract void writeQualifiedName(char[] localName, char[] ns);

Writes out the namespace-qualified name.

abstract void writeRaw(char[] data);

Writes raw markup from a string.

abstract void writeRaw(char[] buffer, int index, int count);

Writes raw markup from a character buffer.

abstract void writeStartDocument(bool standalone);
abstract void writeStartDocument();

Writes the XML declaration.

Parameters
bool standalone
If true, writes "standalone=yes"; if false, "standalone=no".

abstract void writeStartElement(char[] prefix, char[] localName, char[] ns);
final void writeStartElement(char[] localName, char[] ns);
final void writeStartElement(char[] localName);

Writes the specified start tag.

abstract void writeString(char[] text);

Writes the specified text content.

abstract void writeWhitespace(char[] ws);

Writes out the specified white space.

abstract void flush();

Flushes whatever is in the buffer to the underlying stream, then flushes the underlying stream.

abstract void writeBase64(void[] buffer, int index, int count);

Encodes the specified binary bytes as Base64 and writes out the resulting text.