Unicorn XML Toolkit
Version 1.50.00

Namespace Xml
Class CDomWriter

class CDomWriter: public SaxSxp::CContentHandlerAdapter {
public:
    CDomWriter(
        CToolkitBase *pToolkitBase, 
        Dom::INode *pNode=NULL);
    ~CDomWriter();
public:
    void StartDocument();
    void EndDocument();
public:
    void SetNode(Dom::INode *pNode);
    Dom::XNode GetNode();
    void SetNamespaces(bool bNamespaces);
    bool GetNamespaces();
    void PreserveSpace(
        const WCHAR *pszNamespaceUri=NULL,
        const WCHAR *pszLocalName=NULL);
    void StripSpace(
        const WCHAR *pszNamespaceUri=NULL,
        const WCHAR *pszLocalName=NULL);
    };
typedef XInterface<CDomWriter> XDomWriter;

The DOM writer.

This is the subclass of SAX XML content handler, which receives the stream of SAX content events, converting them into a DOM/XDM document fragment, which it builds under specified parent node.

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 SAX to DOM/XDM.

Any DOM/XDM node, which is allowed to have children may serve as a target sub-tree root. In particular, if an empty document node is specified as the root the writer will build the entire document tree based on the content of the source events.

For each particular DOM writer, the application programmer can specify, whether source events must provide namespace information, obtained as the result of SAX namespace processing.

Technically, this class subclasses the internal toolkit class SaxSxp::CContentHandlerAdapter , which is in turn a subclass of Sax::CContentHandler and implements all standard methods of SAX content handlers.

This class supports the whitespace stripping functionality. The application programmer may specify names of elements, for which the whitespaces (that is, text nodes containing whitespace characters only) must be removed (stripped) from the result tree. The whitespace stripping technique is similar to one described in XSL Transformations (XSLT) Version 1.0. .

Since:
1.50.00
Version:
1.50.00
Author:
Alexey Gokhberg
See Also:
CToolkitBase, Dom::INode
Constructor/Destructor Summary
CDomWriter (CToolkitBase *pToolkitBase, Dom::INode *pNode=NULL);
����������Constructs the DOM writer.
~CDomWriter ();
����������Destroys the DOM writer.

Function Summary
void StartDocument ();
����������Receives notification of the beginning of a document.
void EndDocument ();
����������Receives notification of the end of a document.
void SetNode (Dom::INode *pNode);
����������Sets the node serving as the parent for a sub-tree to be built.
Dom::XNode GetNode ();
����������Returns a parent node of a sub-tree to be built.
void SetNamespaces (bool bNamespaces);
����������Specifies whether the source content events must provide namespace information obtained as the result of SAX namespace processing.
bool GetNamespaces ();
����������Tests whether the source events must provide namespace information obtained as the result of SAX namespace processing.
void PreserveSpace (const WCHAR *pszNamespaceUri=NULL, const WCHAR *pszLocalName=NULL);
����������Requests preserving whitespaces on elements with the specified namespace URI and local name.
void StripSpace (const WCHAR *pszNamespaceUri=NULL, const WCHAR *pszLocalName=NULL);
����������Requests stripping whitespaces on elements with the specified namespace URI and local name.

Constructor/Destructor Detail

CDomWriter

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

Constructs the DOM writer.

Parameters:
pToolkitBase - the master toolkit base
pNode - the node serving as the parent for a sub-tree to be built. If this parameter is set to NULL at construction time, the actual node must be specified using the SetNode method before starting the source stream of SAX content events.

~CDomWriter

~CDomWriter();

Destroys the DOM writer.

Function Detail

StartDocument

void StartDocument();

Receives notification of the beginning of a document.

EndDocument

void EndDocument();

Receives notification of the end of a document.

SetNode

void SetNode(Dom::INode *pNode);

Sets the node serving as the parent for a sub-tree to be built.

Parameters:
pNode - the node serving as the parent for a sub-tree to be built

GetNode

Dom::XNode GetNode();

Returns a parent node of a sub-tree to be built.

Returns:
a parent node of a sub-tree to be built

SetNamespaces

void SetNamespaces(bool bNamespaces);

Specifies whether the source content events must provide namespace information obtained as the result of SAX namespace processing.

Parameters:
bNamespaces - true if namespace information is required in the source; false otherwise

GetNamespaces

bool GetNamespaces();

Tests whether the source events must provide namespace information obtained as the result of SAX namespace processing.

Returns:
true if namespace information is required in the source; false otherwise

PreserveSpace

void PreserveSpace(
    const WCHAR *pszNamespaceUri=NULL,
    const WCHAR *pszLocalName=NULL);

Requests preserving whitespaces on elements with the specified namespace URI and local name.

If the namespace URI is set to NULL , whitespaces are preserved on all elements. If the local name is set to NULL , whitespaces are preserved on all elements with the given namespace URI.

Parameters:
pszNamespaceUri - the namespace URI
pszLocalName - the local name

StripSpace

void StripSpace(
    const WCHAR *pszNamespaceUri=NULL,
    const WCHAR *pszLocalName=NULL);

Requests stripping whitespaces on elements with the specified namespace URI and local name.

If the namespace URI is set to NULL , whitespaces are stripped on all elements. If the local name is set to NULL , whitespaces are stripped on all elements with the given namespace URI.

Parameters:
pszNamespaceUri - the namespace URI
pszLocalName - the local name

Unicorn XML Toolkit
Version 1.50.00


This document was created using Unicorn DOC++.

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