|
1 /** @file |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Xml responses serialization filter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "upnpxmlcontentfilter.h" |
|
21 |
|
22 #include <e32svr.h> |
|
23 |
|
24 #include <xml/parser.h> |
|
25 #include <xml/parserfeature.h> |
|
26 #include <xmlengnodefilter.h> |
|
27 #include <xmlengdomparser.h> |
|
28 |
|
29 #include <charconv.h> |
|
30 #include <utf.h> |
|
31 |
|
32 using namespace Xml; |
|
33 |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CUpnpXmlContentFilter::AcceptNode |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 TXmlEngNodeFilterResult CUpnpXmlContentFilter::AcceptNode( TXmlEngNode aNode ) |
|
40 { |
|
41 if ( aNode.NodeType() == TXmlEngNode::ECDATASection || |
|
42 aNode.NodeType() == TXmlEngNode::EComment ) |
|
43 { |
|
44 return EReject; |
|
45 } |
|
46 return EAccept; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CUpnpXmlContentFilter::SerializeLC |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 HBufC8* CUpnpXmlContentFilter::SerializeLC(RXmlEngDocument& aDoc, TXmlEngElement& aElement ) |
|
54 { |
|
55 CUpnpXmlContentFilter* nodefilter = new (ELeave) CUpnpXmlContentFilter(); |
|
56 CleanupStack::PushL(nodefilter); |
|
57 |
|
58 RBuf8 buf; |
|
59 CleanupClosePushL( buf ); |
|
60 |
|
61 TXmlEngSerializationOptions options( TXmlEngSerializationOptions::KOptionOmitXMLDeclaration |
|
62 | TXmlEngSerializationOptions::KOptionIncludeNsPrefixes); |
|
63 options.SetNodeFilter(nodefilter); |
|
64 aDoc.SaveL( buf, aElement, options ); |
|
65 |
|
66 HBufC8* res = buf.AllocL(); |
|
67 CleanupStack::PopAndDestroy( &buf ); |
|
68 CleanupStack::PopAndDestroy( nodefilter ); |
|
69 CleanupStack::PushL(res); |
|
70 |
|
71 return res; |
|
72 } |
|
73 |
|
74 // end of file |