root / windows / trunk / libs / poco / include / Poco / DOM / DOMSerializer.h @ 23

View | Annotate | Download (4.7 KB)

1
//
2
// DOMSerializer.h
3
//
4
// $Id: //poco/1.3/XML/include/Poco/DOM/DOMSerializer.h#2 $
5
//
6
// Library: XML
7
// Package: DOM
8
// Module:  DOMSerializer
9
//
10
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11
// and Contributors.
12
//
13
// Permission is hereby granted, free of charge, to any person or organization
14
// obtaining a copy of the software and accompanying documentation covered by
15
// this license (the "Software") to use, reproduce, display, distribute,
16
// execute, and transmit the Software, and to prepare derivative works of the
17
// Software, and to permit third-parties to whom the Software is furnished to
18
// do so, all subject to the following:
19
// 
20
// The copyright notices in the Software and this entire statement, including
21
// the above license grant, this restriction and the following disclaimer,
22
// must be included in all copies of the Software, in whole or in part, and
23
// all derivative works of the Software, unless such copies or derivative
24
// works are solely in the form of machine-executable object code generated by
25
// a source language processor.
26
// 
27
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
30
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
31
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
32
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33
// DEALINGS IN THE SOFTWARE.
34
//
35
36
37
#ifndef DOM_DOMSerializer_INCLUDED
38
#define DOM_DOMSerializer_INCLUDED
39
40
41
#include "Poco/XML/XML.h"
42
#include "Poco/SAX/XMLReader.h"
43
44
45
namespace Poco {
46
namespace XML {
47
48
49
class Node;
50
class Element;
51
class Text;
52
class Comment;
53
class ProcessingInstruction;
54
class Entity;
55
class CDATASection;
56
class Notation;
57
class Document;
58
class DocumentType;
59
class DocumentFragment;
60
class DeclHandler;
61
class LexicalHandler;
62
63
64
class XML_API DOMSerializer: public XMLReader
65
        /// The DOMSerializer serializes a DOM document
66
        /// into a sequence of SAX events which are
67
        /// reported to the registered SAX event
68
        /// handlers.
69
        ///
70
        /// The DOMWriter uses a DOMSerializer with an
71
        /// XMLWriter to serialize a DOM document into
72
        /// textual XML.
73
{
74
public:
75
        DOMSerializer();
76
                /// Creates the DOMSerializer.
77
                
78
        ~DOMSerializer();
79
                /// Destroys the DOMSerializer.
80
                
81
        void serialize(const Node* pNode);
82
                /// Serializes a DOM node and its children
83
                /// into a sequence of SAX events, which are
84
                /// reported to the registered SAX event
85
                /// handlers.
86
87
        // XMLReader
88
        void setEntityResolver(EntityResolver* pResolver);
89
        EntityResolver* getEntityResolver() const;
90
        void setDTDHandler(DTDHandler* pDTDHandler);
91
        DTDHandler* getDTDHandler() const;
92
        void setContentHandler(ContentHandler* pContentHandler);
93
        ContentHandler* getContentHandler() const;
94
        void setErrorHandler(ErrorHandler* pErrorHandler);
95
        ErrorHandler* getErrorHandler() const;
96
97
        void setFeature(const XMLString& featureId, bool state);
98
        bool getFeature(const XMLString& featureId) const;
99
        void setProperty(const XMLString& propertyId, const XMLString& value);
100
        void setProperty(const XMLString& propertyId, void* value);
101
        void* getProperty(const XMLString& propertyId) const;
102
103
protected:
104
        void parse(InputSource* pSource);
105
                /// The DOMSerializer cannot parse an InputSource,
106
                /// so this method simply throws an XMLException when invoked.
107
                
108
        void parse(const XMLString& systemId);
109
                /// The DOMSerializer cannot parse from a system identifier,
110
                /// so this method simply throws an XMLException when invoked.
111
112
        void parseMemoryNP(const char* xml, std::size_t size);
113
                /// The DOMSerializer cannot parse from a system identifier,
114
                /// so this method simply throws an XMLException when invoked.
115
116
        void iterate(const Node* pNode) const;
117
        void handleNode(const Node* pNode) const;
118
        void handleElement(const Element* pElement) const;
119
        void handleCharacterData(const Text* pText) const;
120
        void handleComment(const Comment* pComment) const;
121
        void handlePI(const ProcessingInstruction* pPI) const;
122
        void handleCDATASection(const CDATASection* pCDATA) const;
123
        void handleDocument(const Document* pDocument) const;
124
        void handleDocumentType(const DocumentType* pDocumentType) const;
125
        void handleFragment(const DocumentFragment* pFragment) const;
126
        void handleNotation(const Notation* pNotation) const;
127
        void handleEntity(const Entity* pEntity) const;
128
129
private:
130
        EntityResolver* _pEntityResolver;
131
        DTDHandler*     _pDTDHandler;
132
        ContentHandler* _pContentHandler;
133
        ErrorHandler*   _pErrorHandler;
134
        DeclHandler*    _pDeclHandler;
135
        LexicalHandler* _pLexicalHandler;
136
        
137
        static const XMLString CDATA;
138
};
139
140
141
} } // namespace Poco::XML
142
143
144
#endif // DOM_DOMSerializer_INCLUDED