Rogue Wave Views
Foundation Package API Reference Guide
Product Documentation:

Rogue Wave Views
Documentation Home
List of all members | Public Member Functions | Protected Member Functions
IlXmlDocumentI Class Referenceabstract

Interface for XML documents. More...

#include <ilog/xml.h>

Inheritance diagram for IlXmlDocumentI:
IlXmlDocument

Public Member Functions

virtual ~IlXmlDocumentI ()
 Destructor. More...
 
virtual void addNode (IlXmlNodeI *node)=0
 Adds a new node. More...
 
virtual void attributeAdded (IlXmlElementI *element, IlXmlAttributeI *attribute)
 Receives notification of the creation of an attribute. More...
 
virtual void cDataAdded (IlXmlCDataI *cdata)
 Receives notification of the creation of a CDATA node. More...
 
virtual void charRefAdded (IlXmlCharRefI *charRef)
 Receives notification of the creation of a CharRef. More...
 
virtual void commentAdded (IlXmlCommentI *comment)
 Receives notification of the creation of a comment. More...
 
virtual IlXmlAttributeIcreateAttribute (IlXmlElementI *element, char *name, char *value) const
 Creates a new XML attribute for a given element. More...
 
virtual IlXmlCDataIcreateCData () const
 Creates a new XML CDATA node. More...
 
virtual IlXmlCharRefIcreateCharRef () const
 Creates a new XML CharRef node. More...
 
virtual IlXmlCommentIcreateComment () const
 Creates a new XML comment node. More...
 
virtual IlXmlElementIcreateElement (char *tag) const
 Creates a new XML element. More...
 
virtual IlXmlNodeIteratorIcreateNodesIterator () const
 Creates an iterator for the nodes of this document. More...
 
virtual IlXmlPIIcreatePI () const
 Creates a new XML processing instruction node. More...
 
virtual IlXmlTextIcreateText () const
 Creates a new XML text node. More...
 
virtual void empty ()
 Empties this document. More...
 
virtual void endElement (IlXmlElementI *element)
 Receives notification of the end of an element. More...
 
virtual IlXmlNodeFactorygetNodeFactory () const
 Gets the node factory of this document. More...
 
virtual const char * getVersion () const
 Gets the version of the document. More...
 
virtual void processingInstructionAdded (IlXmlPII *pi)
 Receives notification of the creation of a processing instruction node. More...
 
void read (std::istream &stream)
 Reads an XML document. More...
 
virtual void startElement (IlXmlElementI *element)
 Receives notification of the creation of an element. More...
 
virtual void textAdded (IlXmlTextI *text)
 Receives notification of the creation of a text node. More...
 
virtual std::ostream & write (std::ostream &stream) const
 Writes an XML document. More...
 
virtual void writeNodes (std::ostream &stream) const
 Writes the XML nodes of this document. More...
 

Protected Member Functions

virtual void storeVersion (char *version)
 Stores the XML version. More...
 

Detailed Description

Interface for XML documents.

Library: ilog

This interface defines the entire interface of XML document objects.
An IlXmlDocumentI can parse an XML file and produce XML nodes that you can work with.
It can also save itself as a valid XML document.

Constructor & Destructor Documentation

§ ~IlXmlDocumentI()

virtual IlXmlDocumentI::~IlXmlDocumentI ( )
virtual

Destructor.

The destructor must free all the nodes stored in this document. The default implementation does nothing, but subclasses of IlXmlDocumentI should perform, in their destructor, a call to their implementation of empty.

Member Function Documentation

§ addNode()

virtual void IlXmlDocumentI::addNode ( IlXmlNodeI node)
pure virtual

Adds a new node.

This method is called when the XML parser creates a top-level node. It can be an element (then it is unique, and considered as the root element of the document), a comment or a processing instruction.

Parameters
nodeA pointer to the new node.

Implemented in IlXmlDocument.

§ attributeAdded()

virtual void IlXmlDocumentI::attributeAdded ( IlXmlElementI element,
IlXmlAttributeI attribute 
)
virtual

Receives notification of the creation of an attribute.

This method is called when the XML parser creates a new attribute (that is, when it detects a name-attribute value pair within a tag). The attribute is initialized with the attribute name and its value, but is not stored in the node yet.

Parameters
elementA pointer to the element where this attribute is stored.
attributeA pointer to the new attribute.

§ cDataAdded()

virtual void IlXmlDocumentI::cDataAdded ( IlXmlCDataI cdata)
virtual

Receives notification of the creation of a CDATA node.

This method is called when the XML parser finds a CDATA chunk in its input stream (that is, a block surrounded by <![CDATA[... ]]>). The CDATA node is initialized with the content that was found but is not stored in the document yet.

Parameters
cdataA pointer to the new CDATA node.

§ charRefAdded()

virtual void IlXmlDocumentI::charRefAdded ( IlXmlCharRefI charRef)
virtual

Receives notification of the creation of a CharRef.

This method is called when the XML parser finds a CharRef entity in its input stream (that is, a &#, &#x or &name sequence). The CharRef node is initialized with the reference that was found but is not stored in the document yet.

Parameters
charRefA pointer to the new CharRef node.

§ commentAdded()

virtual void IlXmlDocumentI::commentAdded ( IlXmlCommentI comment)
virtual

Receives notification of the creation of a comment.

This method is called when the XML parser finds a comment in its input stream (that is, a <!– ... –> sequence). The comment node is initialized with the comment that was found but is not stored in the document yet.

Parameters
commentA pointer to the new comment node.

§ createAttribute()

virtual IlXmlAttributeI* IlXmlDocumentI::createAttribute ( IlXmlElementI element,
char *  name,
char *  value 
) const
virtual

Creates a new XML attribute for a given element.

Parameters
elementThe element that will store the new attribute.
nameThe attribute name.
valueThe attribute value.
Returns
A pointer to a new XML attribute.
The default implementation calls the method IlXmlElementI::createAttribute() on the indicated element with the provided attribute name and value parameters.
If this call returns 0, then the library calls IlXmlNodeFactory::createAttribute() of this document node factory, if there is one.
If there is no node factory, or if the returned value is 0, a new IlXmlAttribute object is created, initialized with name and value, then returned.
See also
getNodeFactory().

§ createCData()

virtual IlXmlCDataI* IlXmlDocumentI::createCData ( ) const
virtual

Creates a new XML CDATA node.

Returns
A pointer to a new XML CDATA node.
The default implementation calls the method IlXmlNodeFactory::createCData() of this document node factory, if there is one.
If there is no factory, or if the returned value is 0, a new IlXmlCData object is created and returned.
See also
getNodeFactory().

§ createCharRef()

virtual IlXmlCharRefI* IlXmlDocumentI::createCharRef ( ) const
virtual

Creates a new XML CharRef node.

Returns
A pointer to a new XML CharRef node.
The default implementation calls the method IlXmlNodeFactory::createCharRef() of this document node factory, if there is one.
If there is no factory, or if the returned value is 0, a new empty IlXmlCharRef object is created and returned.
See also
getNodeFactory().

§ createComment()

virtual IlXmlCommentI* IlXmlDocumentI::createComment ( ) const
virtual

Creates a new XML comment node.

Returns
A pointer to a new XML comment node.
The default implementation calls the method IlXmlNodeFactory::createComment() of this document node factory, if there is one.
If there is no factory, or if the returned value is 0, a new empty IlXmlComment object is created and returned.
See also
getNodeFactory().

§ createElement()

virtual IlXmlElementI* IlXmlDocumentI::createElement ( char *  tag) const
virtual

Creates a new XML element.

Parameters
tagThe tag name of the new element. This must be stored in the new element, or deleted if not used.
Returns
A pointer to a new XML element.
The default implementation calls the method IlXmlNodeFactory::createElement() of this document node factory, if there is one.
If there is no factory, or if the returned value is 0, the default implementation creates a new IlXmlElement, initialized with the tag name tag.
Then the created element is returned.
See also
getNodeFactory().

§ createNodesIterator()

virtual IlXmlNodeIteratorI* IlXmlDocumentI::createNodesIterator ( ) const
virtual

Creates an iterator for the nodes of this document.

Returns
A new instance of an iterator for all the nodes stored in this document. The caller is responsible for the destruction of this iterator.

Reimplemented in IlXmlDocument.

§ createPI()

virtual IlXmlPII* IlXmlDocumentI::createPI ( ) const
virtual

Creates a new XML processing instruction node.

Returns
A pointer to a new XML PI node.
The default implementation calls the method IlXmlNodeFactory::createPI() of this document node factory, if there is one.
If there is no factory, or if the returned value is 0, a new IlXmlPI object is created and returned.
See also
getNodeFactory().

§ createText()

virtual IlXmlTextI* IlXmlDocumentI::createText ( ) const
virtual

Creates a new XML text node.

Returns
A pointer to a new XML text node.
The default implementation calls the method IlXmlNodeFactory::createText() of this document node factory, if there is one.
If there is no factory, or if the returned value is 0, a new empty IlXmlText object is created and returned.
See also
getNodeFactory().

§ empty()

virtual void IlXmlDocumentI::empty ( )
virtual

Empties this document.

Removes and destroys all the nodes stored in this document. The default implementation does nothing.

Reimplemented in IlXmlDocument.

§ endElement()

virtual void IlXmlDocumentI::endElement ( IlXmlElementI element)
virtual

Receives notification of the end of an element.

This method is called when the XML parser finds the closing tag (that is, a </tag> sequence). The element is completely initialized (tag name and attributes), but is not stored in the document yet.

Parameters
elementA pointer to the element that is ending.

§ getNodeFactory()

virtual IlXmlNodeFactory* IlXmlDocumentI::getNodeFactory ( ) const
virtual

Gets the node factory of this document.

The default implementation returns 0.

Returns
A pointer to this document node factory, or 0 if there is none.

§ getVersion()

virtual const char* IlXmlDocumentI::getVersion ( ) const
virtual

Gets the version of the document.

The default implementation returns the string "1.0".

Returns
A string that describes the version of this document. The string must not be deleted or modified.
See also
storeVersion().

Reimplemented in IlXmlDocument.

§ processingInstructionAdded()

virtual void IlXmlDocumentI::processingInstructionAdded ( IlXmlPII pi)
virtual

Receives notification of the creation of a processing instruction node.

This method is called when the XML parser finds a processing instruction in its input stream (that is, a <? ... ?>, sequence). The PI node is initialized with the processing instruction content that was found but is not stored in the document yet.

Parameters
piA pointer to the new PI node.

§ read()

void IlXmlDocumentI::read ( std::istream &  stream)

Reads an XML document.

This method empties the document (by calling the method empty()), then reads the input stream in order to parse the XML content of it.

On Windows, if the stream is an ifstream, it must be opened in binary mode.

Parameters
streamThe input stream from which the XML data is read.

§ startElement()

virtual void IlXmlDocumentI::startElement ( IlXmlElementI element)
virtual

Receives notification of the creation of an element.

This method is called when the XML parser finds a starting tag (that is, a <tag> sequence). The element is initialized with the tag name, but has no attributes, and is not stored in the document yet.

Parameters
elementA pointer to the new element.

§ storeVersion()

virtual void IlXmlDocumentI::storeVersion ( char *  version)
protectedvirtual

Stores the XML version.

The default implementation deletes the string and does not store it anywhere.

Parameters
versionThe new version of this document. The string is stored as is and is not copied by the document.

Reimplemented in IlXmlDocument.

§ textAdded()

virtual void IlXmlDocumentI::textAdded ( IlXmlTextI text)
virtual

Receives notification of the creation of a text node.

This method is called when the XML parser finds a text section in its input stream. The text node is initialized with the text that was found but is not stored in the document yet.

Parameters
textA pointer to the new text node.

§ write()

virtual std::ostream& IlXmlDocumentI::write ( std::ostream &  stream) const
virtual

Writes an XML document.

This method saves the entire document as a valid XML stream. After saving the XML file header, this member function calls writeNodes().

Parameters
streamThe output stream where the XML data is output.
Returns
A reference to stream.

§ writeNodes()

virtual void IlXmlDocumentI::writeNodes ( std::ostream &  stream) const
virtual

Writes the XML nodes of this document.

Parameters
streamThe output stream where the XML data is output.

© Copyright 2017, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.