28 #include "../StdAfx.h"
29 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
33 static const XMLCh gEndElement[] = { chOpenAngle, chForwardSlash, chNull };
38 chLatin_U, chLatin_T,chLatin_F, chDash,chDigit_8, chNull
43 chDigit_1,chPeriod,chDigit_0, chNull
48 chOpenAngle,chQuestion,chLatin_x,chLatin_m,chLatin_l,chSpace,
49 chLatin_v,chLatin_e,chLatin_r,chLatin_s,chLatin_i,chLatin_o,chLatin_n,chEqual,
50 chDoubleQuote,chDigit_1,chPeriod,chDigit_0,chDoubleQuote,chSpace,
51 chLatin_e,chLatin_n,chLatin_c,chLatin_o,chLatin_d,chLatin_i,chLatin_n,chLatin_g,chEqual,
52 chDoubleQuote,chLatin_U, chLatin_T,chLatin_F, chDash,chDigit_8, chDoubleQuote,
53 chSpace,chQuestion, chCloseAngle, chLF, chNull
85 const XMLCh* pNodeName = toWrite->getNodeName();
87 switch (toWrite->getNodeType())
89 case DOMNode::TEXT_NODE:
91 const XMLCh* pNodeValue = toWrite->getNodeValue();
92 if (pNodeValue == NULL)
96 m_pFormatter->formatBuf(pNodeValue,XMLString::stringLen(pNodeValue),XMLFormatter::CharEscapes);
100 XMLCh* pText=XMLString::replicate(pNodeValue);
101 XMLString::trim(pText);
102 char* tmpStr=XMLString::transcode(pText);
103 m_pFormatter->formatBuf(pText,XMLString::stringLen(pText),XMLFormatter::CharEscapes);
104 XMLString::release(&pText);
105 XMLString::release(&tmpStr);
123 case DOMNode::DOCUMENT_NODE :
125 case DOMNode::DOCUMENT_FRAGMENT_NODE :
128 DOMNode* pChild = toWrite->getFirstChild();
129 while( pChild != NULL)
135 pChild = pChild->getNextSibling();
141 case DOMNode::ELEMENT_NODE :
145 << chOpenAngle << pNodeName;
150 DOMNamedNodeMap* pAttributes = toWrite->getAttributes();
151 UINT32 attrCount = pAttributes->getLength();
152 const XMLCh** attr_names=NULL;
153 UINT32* sort_indices=NULL;
156 attr_names=
new const XMLCh*[attrCount];
157 sort_indices=
new UINT32[attrCount];
158 for(
UINT32 i=0;i<attrCount;i++)
160 DOMNode* pAttribute = pAttributes->item(i);
161 attr_names[i]=pAttribute->getNodeName();
167 for(
UINT32 i=0;i<attrCount;i++)
169 const XMLCh *akt=attr_names[sort_indices[i]];
170 for(
UINT32 j=i+1;j<attrCount;j++)
172 const XMLCh* tmp=attr_names[sort_indices[j]];
173 if(XMLString::compareString(akt,tmp)>0)
176 sort_indices[i]=sort_indices[j];
185 for (
UINT32 i = 0; i < attrCount; i++)
188 DOMNode* pAttribute = pAttributes->item(sort_indices[i]);
196 << chSpace << pAttribute->getNodeName()
197 << chEqual << chDoubleQuote
198 << XMLFormatter::AttrEscapes
199 << pAttribute->getNodeValue()
200 << XMLFormatter::NoEscapes
203 *
m_pFormatter << XMLFormatter::NoEscapes << chCloseAngle;
207 delete[] sort_indices;
214 DOMNode* pChild = toWrite->getFirstChild();
215 while( pChild != NULL)
218 pChild = pChild->getNextSibling();
222 << pNodeName << chCloseAngle;
static const XMLCh m_UTF8[6]
XMLFormatter * m_pFormatter
static const XMLCh m_XML[41]
static const XMLCh m_1_0[4]
SINT32 dumpNode(const DOMNode *toWrite, bool bCanonical)
Dumps a Node of an XML Document.