20 |
20 |
21 // INCLUDES |
21 // INCLUDES |
22 #include <XdmDocument.h> |
22 #include <XdmDocument.h> |
23 #include <XdmDocumentNode.h> |
23 #include <XdmDocumentNode.h> |
24 #include <XdmNodeAttribute.h> |
24 #include <XdmNodeAttribute.h> |
25 |
|
26 #include "XdmLogWriter.h" |
|
27 #include "XmlFormatter.h" |
25 #include "XmlFormatter.h" |
28 #include "XmlParserDefines.h" |
26 #include "XmlParserDefines.h" |
29 #include "XmlParserNodePath.h" |
27 #include "XmlParserNodePath.h" |
30 #include "XdmXmlParser.h" |
|
31 |
28 |
32 // ---------------------------------------------------------- |
29 // ---------------------------------------------------------- |
33 // CXmlFormatter::CXmlFormatter |
30 // CXmlFormatter::CXmlFormatter |
34 // |
31 // |
35 // ---------------------------------------------------------- |
32 // ---------------------------------------------------------- |
292 // ---------------------------------------------------------- |
289 // ---------------------------------------------------------- |
293 // |
290 // |
294 void CXmlFormatter::FormatNamespaceDeclarationsL( const CXdmDocumentNode& aRootNode, |
291 void CXmlFormatter::FormatNamespaceDeclarationsL( const CXdmDocumentNode& aRootNode, |
295 const MXdmNamespaceContainer& aContainer ) |
292 const MXdmNamespaceContainer& aContainer ) |
296 { |
293 { |
297 #ifdef _DEBUG |
|
298 iParserMain.WriteToLog( _L8( "CXmlFormatter::FormatNamespaceDeclarationsL start" ) ); |
|
299 #endif |
|
300 TPtrC8 name( aRootNode.EightBitNodeNameLC()->Des() ); |
294 TPtrC8 name( aRootNode.EightBitNodeNameLC()->Des() ); |
301 TPtrC8 prefix = Prefix( aRootNode ); |
295 TPtrC8 prefix = Prefix( aRootNode ); |
302 iFormatBuffer->InsertL( iFormBufferPos, KStartBracketString ); |
296 iFormatBuffer->InsertL( iFormBufferPos, KStartBracketString ); |
303 iFormBufferPos = iFormBufferPos + KStartBracketString().Length(); |
297 iFormBufferPos = iFormBufferPos + KStartBracketString().Length(); |
304 if( prefix.Length() > 0 ) |
298 if( prefix.Length() > 0 ) |
320 uri.Set( aContainer.Uri( i ) ); |
314 uri.Set( aContainer.Uri( i ) ); |
321 prefix.Set( aContainer.Prefix( i ) ); |
315 prefix.Set( aContainer.Prefix( i ) ); |
322 AppendNamespaceL( uri, prefix ); |
316 AppendNamespaceL( uri, prefix ); |
323 } |
317 } |
324 } |
318 } |
325 |
|
326 // go through possible attributes after namespaces |
|
327 for ( TInt i = 0; i < aRootNode.AttributeCount(); i++ ) |
|
328 { |
|
329 iFormatBuffer->InsertL( iFormBufferPos, KSpaceString ); |
|
330 iFormBufferPos = iFormBufferPos + KSpaceString().Length(); |
|
331 |
|
332 CXdmNodeAttribute* attr = aRootNode.Attribute( i ); |
|
333 TPtrC8 name( attr->EightBitNodeNameLC()->Des() ); |
|
334 iFormatBuffer->InsertL( iFormBufferPos, name ); |
|
335 iFormBufferPos = iFormBufferPos + name.Length(); |
|
336 CleanupStack::PopAndDestroy(); //EightBitNodeNameLC() |
|
337 iFormatBuffer->InsertL( iFormBufferPos, KEquelsSignString ); |
|
338 iFormBufferPos = iFormBufferPos + KEquelsSignString().Length(); |
|
339 iFormatBuffer->InsertL( iFormBufferPos, KQuotationSignString ); |
|
340 iFormBufferPos = iFormBufferPos + KQuotationSignString().Length(); |
|
341 TPtrC8 attrValue( attr->EightBitValueLC()->Des() ); |
|
342 iFormatBuffer->InsertL( iFormBufferPos, attrValue ); |
|
343 iFormBufferPos = iFormBufferPos + attrValue.Length(); |
|
344 CleanupStack::PopAndDestroy(); //EightBitValueLC() |
|
345 iFormatBuffer->InsertL( iFormBufferPos, KQuotationSignString ); |
|
346 iFormBufferPos = iFormBufferPos + KQuotationSignString().Length(); |
|
347 } |
|
348 |
|
349 iFormatBuffer->InsertL( iFormBufferPos, KEndBracketString ); |
319 iFormatBuffer->InsertL( iFormBufferPos, KEndBracketString ); |
350 iFormBufferPos = iFormBufferPos + KEndBracketString().Length(); |
320 iFormBufferPos = iFormBufferPos + KEndBracketString().Length(); |
351 iFormatBuffer->InsertL( iFormBufferPos, KNewlineString ); |
321 iFormatBuffer->InsertL( iFormBufferPos, KNewlineString ); |
352 iFormBufferPos = iFormBufferPos + KNewlineString().Length(); |
322 iFormBufferPos = iFormBufferPos + KNewlineString().Length(); |
353 #ifdef _DEBUG |
|
354 iParserMain.WriteToLog( _L8( "CXmlFormatter::FormatNamespaceDeclarationsL exit" ) ); |
|
355 #endif |
|
356 } |
323 } |
357 |
324 |
358 // --------------------------------------------------------- |
325 // --------------------------------------------------------- |
359 // CXmlFormatter::FormatLeafElementL |
326 // CXmlFormatter::FormatLeafElementL |
360 // |
327 // |