root / Community Core Vision / Linux / libs / poco / include / Poco / DOM / DOMSerializer.h @ 9

View | Annotate | Download (4.7 KB)

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