File indexing completed on 2025-01-30 10:27:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_DOMLSSERIALIZERMPL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DOMLSSERIALIZERMPL_HPP
0024
0025 #include <xercesc/dom/DOM.hpp>
0026 #include <xercesc/dom/DOMLSSerializer.hpp>
0027 #include <xercesc/util/XMLDOMMsg.hpp>
0028 #include <xercesc/util/RefHashTableOf.hpp>
0029 #include <xercesc/util/RefVectorOf.hpp>
0030 #include <xercesc/framework/XMLFormatter.hpp>
0031
0032 XERCES_CPP_NAMESPACE_BEGIN
0033
0034 class DOMStringListImpl;
0035
0036 class CDOM_EXPORT DOMLSSerializerImpl : public XMemory,
0037 public DOMLSSerializer,
0038 public DOMConfiguration
0039 {
0040
0041 public:
0042
0043
0044
0045
0046
0047
0048
0049 DOMLSSerializerImpl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0050
0051
0052
0053
0054 ~DOMLSSerializerImpl();
0055
0056
0057
0058
0059
0060 virtual DOMConfiguration* getDomConfig();
0061
0062 virtual void setNewLine(const XMLCh* const newLine);
0063 virtual const XMLCh* getNewLine() const;
0064
0065 virtual void setFilter(DOMLSSerializerFilter *filter);
0066 virtual DOMLSSerializerFilter* getFilter() const;
0067
0068 virtual bool write(const DOMNode* nodeToWrite,
0069 DOMLSOutput* const destination);
0070 virtual bool writeToURI(const DOMNode* nodeToWrite,
0071 const XMLCh* uri);
0072
0073
0074
0075 virtual XMLCh* writeToString(const DOMNode* nodeToWrite, MemoryManager* manager = NULL);
0076 virtual void release();
0077
0078
0079
0080
0081
0082 virtual void setParameter(const XMLCh* name, const void* value);
0083 virtual void setParameter(const XMLCh* name, bool value);
0084 virtual const void* getParameter(const XMLCh* name) const;
0085 virtual bool canSetParameter(const XMLCh* name, const void* value) const;
0086 virtual bool canSetParameter(const XMLCh* name, bool value) const;
0087 virtual const DOMStringList* getParameterNames() const;
0088
0089
0090 private:
0091
0092
0093 DOMLSSerializerImpl(const DOMLSSerializerImpl&);
0094 DOMLSSerializerImpl & operator = (const DOMLSSerializerImpl&);
0095
0096 protected:
0097
0098 void processNode(const DOMNode* const);
0099
0100 void procCdataSection(const XMLCh* const nodeValue
0101 , const DOMNode* const nodeToWrite);
0102
0103 void procUnrepCharInCdataSection(const XMLCh* const nodeValue
0104 , const DOMNode* const nodeToWrite);
0105
0106 protected:
0107
0108
0109
0110
0111
0112 virtual bool customNodeSerialize(const DOMNode* const nodeToWrite, int level);
0113
0114 DOMNodeFilter::FilterAction checkFilter(const DOMNode* const) const;
0115
0116 bool checkFeature(const XMLCh* const featName
0117 , bool state
0118 , int& featureId) const;
0119
0120 bool reportError(const DOMNode* const errorNode
0121 , DOMError::ErrorSeverity errorType
0122 , const XMLCh* const errorMsg);
0123 bool reportError(const DOMNode* const errorNode
0124 , DOMError::ErrorSeverity errorType
0125 , XMLDOMMsg::Codes toEmit);
0126
0127 bool canSetFeature(const int featureId
0128 , bool val) const;
0129 void setFeature(const int featureId
0130 , bool val);
0131 bool getFeature(const int featureId) const;
0132
0133 void printNewLine();
0134 void setURCharRef();
0135 bool isDefaultNamespacePrefixDeclared() const;
0136 bool isNamespaceBindingActive(const XMLCh* prefix, const XMLCh* uri) const;
0137 void ensureValidString(const DOMNode* nodeToWrite, const XMLCh* string);
0138
0139
0140 void printIndent(unsigned int level);
0141
0142 void processNode(const DOMNode* const nodeToWrite, int level);
0143
0144 void processBOM();
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190 int fFeatures;
0191 XMLCh *fNewLine;
0192 DOMErrorHandler *fErrorHandler;
0193 DOMLSSerializerFilter *fFilter;
0194 const XMLCh *fDocumentVersion;
0195 DOMStringListImpl *fSupportedParameters;
0196
0197
0198 const XMLCh *fEncodingUsed;
0199 const XMLCh *fNewLineUsed;
0200 XMLFormatter *fFormatter;
0201 int fErrorCount;
0202 int fCurrentLine;
0203 bool fLineFeedInTextNodePrinted;
0204 unsigned int fLastWhiteSpaceInTextNode;
0205 bool fIsXml11;
0206
0207 RefVectorOf< RefHashTableOf<XMLCh> >* fNamespaceStack;
0208 MemoryManager* fMemoryManager;
0209 };
0210
0211 inline DOMConfiguration* DOMLSSerializerImpl::getDomConfig()
0212 {
0213 return this;
0214 }
0215
0216 inline void DOMLSSerializerImpl::setFeature(const int featureId
0217 , bool val)
0218 {
0219 (val)? fFeatures |= (1<<featureId) : fFeatures &= ~(1<<featureId);
0220 }
0221
0222 inline bool DOMLSSerializerImpl::getFeature(const int featureId) const
0223 {
0224 return ((fFeatures & ( 1<<featureId )) != 0) ? true : false;
0225 }
0226
0227 inline void DOMLSSerializerImpl::setURCharRef()
0228 {
0229 fFormatter->setUnRepFlags(XMLFormatter::UnRep_CharRef);
0230 }
0231
0232 XERCES_CPP_NAMESPACE_END
0233
0234 #endif