Unicorn XML Toolkit
Version 1.50.00

Namespace Xml
Class CDomReader

class CDomReader: public Sax::CXmlReader {
public:
    CDomReader(
        CToolkitBase *pToolkitBase, 
        Dom::INode *pNode=NULL);
    ~CDomReader();
public:
    void SetFeature(
        const WCHAR *pszName, bool bValue);
    bool GetFeature(const WCHAR *pszName);
    void SetProperty(
        const WCHAR *pszName, 
        CInterface *pValue);
    CInterface *GetProperty(const WCHAR *pszName);
    void SetEntityResolver(Sax::CEntityResolver *pResolver);
    Sax::CEntityResolver *GetEntityResolver();
    void SetDtdHandler(Sax::CDtdHandler *pHandler);
    Sax::CDtdHandler *GetDtdHandler();
    void SetContentHandler(Sax::CContentHandler *pHandler);
    Sax::CContentHandler *GetContentHandler();
    void SetErrorHandler(Sax::CErrorHandler *pHandler);
    Sax::CErrorHandler *GetErrorHandler();
    void Parse(Sax::CInputSource *pInput);
    void Parse(const WCHAR *pszSystemId);
public:
    void SetNamespaces(bool bNamespaces);
    bool GetNamespaces();
    void SetInputSource(Sax::CInputSource *pInputSource);
    Sax::CInputSource *GetInputSource();
    void Start();
public:
    void SetNode(Dom::INode *pNode);
    Dom::XNode GetNode();
    };
typedef XInterface<CDomReader> XDomReader;

The DOM reader.

This is the subclass of SAX XML reader, which reads an XML document fragment from the sub-tree of the source DOM/XDM document, and generates a stream of SAX content events.

Both DOM and XDM document models are supported. (See Dom for a general discussion concerning DOM and XDM document models).

This class effectively implements an adapter from DOM/XDM to SAX.

An arbitrary DOM/XDM node can serve as a root of a sub-tree containing the source data. If the root node represents the DOM/XDM document, the content of the entire document will be transformed into a sequence of events. If the root node has any other type, the content of the sub-tree rooted at this node, including the node itself, will be transformed into a sequence of events. In any case, the generated sequence of events will be started with the StartDocument event and terminated with the EndDocument , even if the root node does not represent the entire document.

For each particular DOM reader, an application programmer can specify, whether this reader must perform SAX namespace processing.

Since:
1.50.00
Version:
1.50.00
Author:
Alexey Gokhberg
See Also:
CToolkitBase, Sax::CDtdHandler, Sax::CEntityResolver, Sax::CContentHandler, Sax::CErrorHandler, Sax::CInputSource, Dom::INode
Constructor/Destructor Summary
CDomReader (CToolkitBase *pToolkitBase, Dom::INode *pNode=NULL);
����������Constructs the DOM reader.
~CDomReader ();
����������Destroys the DOM reader.

Function Summary
void SetFeature (const WCHAR *pszName, bool bValue);
����������Sets the state of a feature.
bool GetFeature (const WCHAR *pszName);
����������Looks up the value of a feature.
void SetProperty (const WCHAR *pszName, CInterface *pValue);
����������Sets the value of a property.
CInterface�* GetProperty (const WCHAR *pszName);
����������Looks up the value of a property.
void SetEntityResolver (Sax::CEntityResolver *pResolver);
����������Allows an application to register an entity resolver.
Sax::CEntityResolver�* GetEntityResolver ();
����������Gets the current entity resolver.
void SetDtdHandler (Sax::CDtdHandler *pHandler);
����������Allows an application to register a DTD event handler.
Sax::CDtdHandler�* GetDtdHandler ();
����������Gets the current DTD handler.
void SetContentHandler (Sax::CContentHandler *pHandler);
����������Allows an application to register a content event handler.
Sax::CContentHandler�* GetContentHandler ();
����������Gets the current content handler.
void SetErrorHandler (Sax::CErrorHandler *pHandler);
����������Allows an application to register an error event handler.
Sax::CErrorHandler�* GetErrorHandler ();
����������Gets the current error handler.
void Parse (Sax::CInputSource *pInput);
����������Parses an XML document.
void Parse (const WCHAR *pszSystemId);
����������Parses an XML document from a system identifier (URI).
void SetNamespaces (bool bNamespaces);
����������Specifies whether content events generated by the reader provide namespace information.
bool GetNamespaces ();
����������Tests whether content events generated by the reader provide namespace information.
void SetInputSource (Sax::CInputSource *pInputSource);
����������Sets the input source.
Sax::CInputSource�* GetInputSource ();
����������Gets the current input source.
void Start ();
����������Starts the DOM reader.
void SetNode (Dom::INode *pNode);
����������Sets the root node of a sub-tree containing the source data.
Dom::XNode GetNode ();
����������Returns the root node of a sub-tree containing the source data.

Constructor/Destructor Detail

CDomReader

CDomReader(
    CToolkitBase *pToolkitBase, 
    Dom::INode *pNode=NULL);

Constructs the DOM reader.

Parameters:
pToolkitBase - the master toolkit base
pNode - the optional root of the sub-tree in the DOM document serving as the source for this DOM reader. If set to NULL at construction time, it must be specified using the SetNode method before starting this DOM reader.

~CDomReader

~CDomReader();

Destroys the DOM reader.

Function Detail

SetFeature

void SetFeature(
    const WCHAR *pszName, bool bValue);

Sets the state of a feature.

See Sax::CXmlReader::SetFeature for a detailed discussion concerning SAX reader features.

Parameters:
pszName - the feature name, which is a fully-qualified URI
bValue - the requested state of the feature ( true or false )

GetFeature

bool GetFeature(const WCHAR *pszName);

Looks up the value of a feature.

See Sax::CXmlReader::GetFeature for a detailed discussion concerning SAX reader features.

Parameters:
pszName - the feature name, which is a fully-qualified URI
Returns:
the current state of the feature ( true or false )

SetProperty

void SetProperty(
    const WCHAR *pszName, 
    CInterface *pValue);

Sets the value of a property.

See Sax::CXmlReader::SetProperty for a detailed discussion concerning SAX reader properties.

Parameters:
pszName - the property name, which is a fully-qualified URI
pValue - the requested value for the property, which is an interface pointer

GetProperty

CInterface *GetProperty(const WCHAR *pszName);

Looks up the value of a property.

See Sax::CXmlReader::GetProperty for a detailed discussion concerning SAX reader properties.

Parameters:
pszName - the property name, which is a fully-qualified URI
Returns:
the current value of the property, which is an interface pointer

SetEntityResolver

void SetEntityResolver(Sax::CEntityResolver *pResolver);

Allows an application to register an entity resolver.

Note that DOM readers do not use entity resolvers, and this method is a stub implemented for the formal SAX compatibility only.

Parameters:
pResolver - the entity resolver

GetEntityResolver

Sax::CEntityResolver *GetEntityResolver();

Gets the current entity resolver.

Returns:
the current entity resolver, or NULL if none has been registered

SetDtdHandler

void SetDtdHandler(Sax::CDtdHandler *pHandler);

Allows an application to register a DTD event handler.

Note that DOM readers do not generate DTD events, and this method is a stub implemented for the formal SAX compatibility only.

Parameters:
pHandler - the DTD handler

GetDtdHandler

Sax::CDtdHandler *GetDtdHandler();

Gets the current DTD handler.

Returns:
the current DTD handler, or NULL if none has been registered

SetContentHandler

void SetContentHandler(Sax::CContentHandler *pHandler);

Allows an application to register a content event handler.

Parameters:
pHandler - the content handler

GetContentHandler

Sax::CContentHandler *GetContentHandler();

Gets the current content handler.

Returns:
the current content handler, or NULL if none has been registered

SetErrorHandler

void SetErrorHandler(Sax::CErrorHandler *pHandler);

Allows an application to register an error event handler.

Note that DOM readers do not generate error events, and this method is a stub implemented for the formal SAX compatibility only.

Parameters:
pHandler - the error handler

GetErrorHandler

Sax::CErrorHandler *GetErrorHandler();

Gets the current error handler.

Returns:
the current error handler, or NULL if none has been registered

Parse

void Parse(Sax::CInputSource *pInput);

Parses an XML document.

Note that, although implementing SAX XML reader interface, DOM readers are not true XML parsers, and this method is a stub implemented for the formal SAX compatibility only. When called, this method throws Sax::CSaxNotSupportedException .

Parameters:
pInput - the input source for the top-level of the XML document

Parse

void Parse(const WCHAR *pszSystemId);

Parses an XML document from a system identifier (URI).

Note that, although implementing SAX XML reader interface, DOM readers are not true XML parsers, and this method is a stub implemented for the formal SAX compatibility only. When called, this method throws Sax::CSaxNotSupportedException .

Parameters:
pszSystemId - the system identifier (URI)

SetNamespaces

void SetNamespaces(bool bNamespaces);

Specifies whether content events generated by the reader provide namespace information.

Parameters:
bNamespaces - true if content events generated by this reader must provide namespace information; false otherwise

GetNamespaces

bool GetNamespaces();

Tests whether content events generated by the reader provide namespace information.

Returns:
true if content events generated by this reader provide namespace information; false otherwise

SetInputSource

void SetInputSource(Sax::CInputSource *pInputSource);

Sets the input source.

Note that, although implementing SAX XML reader interface, DOM readers are not true XML parsers, and this method is a stub implemented for the formal SAX compatibility only. When called, this method throws Sax::CSaxNotSupportedException .

Parameters:
pInputSource - the input source

GetInputSource

Sax::CInputSource *GetInputSource();

Gets the current input source.

Note that, although implementing SAX XML reader interface, DOM readers are not true XML parsers, and this method is a stub implemented for the formal SAX compatibility only. When called, this method throws Sax::CSaxNotSupportedException .

Returns:
the current input source, or NULL if none has been registered

Start

void Start();

Starts the DOM reader.

When started, the DOM reader will provide information about the source DOM/XDM document fragment through the registered content handler.

This method is synchronous: it will not return until reading has ended. If a client application wants to terminate the reader early, it should throw an exception.

SetNode

void SetNode(Dom::INode *pNode);

Sets the root node of a sub-tree containing the source data.

This function cannot be called if the reader is started (that is, the member function Start was called and had not finished processing yet).

Parameters:
pNode - the root node of a sub-tree containing the source data. Both DOM and XDM document models are supported.

GetNode

Dom::XNode GetNode();

Returns the root node of a sub-tree containing the source data.

Returns:
the root node of a sub-tree containing the source data

Unicorn XML Toolkit
Version 1.50.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.