|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // XML Deserializer to DOM tree |
|
15 // |
|
16 |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @publishedAll |
|
22 @released |
|
23 */ |
|
24 #ifndef XMLENGDESERIALIZERDOM_H |
|
25 #define XMLENGDESERIALIZERDOM_H |
|
26 |
|
27 #include <xml/dom/xmlengdeserializer.h> |
|
28 |
|
29 #include <e32std.h> |
|
30 #include <e32base.h> |
|
31 |
|
32 |
|
33 class RFs; |
|
34 class RXmlEngDOMImplementation; |
|
35 class RXmlEngDocument; |
|
36 |
|
37 /** |
|
38 Deserializes a XML file to a DOM tree. |
|
39 |
|
40 Sample code for deserialization to a DOM tree: |
|
41 @code |
|
42 // create deserializer |
|
43 CXmlEngDeserializerDOM* deserializer = CXmlEngDeserializerDOM::NewL(); |
|
44 CleanupStack::PushL(deserializer); |
|
45 // configure deserializer |
|
46 deserializer->SetInputFileL(KInputFile, EDeserializerGZip); |
|
47 // Set the DOM Implementation |
|
48 deserializer->UseDOMImplementationL(iDomImpl); |
|
49 // deserialize |
|
50 RXmlEngDocument doc = deserializer->DeserializeL(); |
|
51 CleanupStack::PopAndDestroy();// deserializer |
|
52 @endcode |
|
53 */ |
|
54 class CXmlEngDeserializerDOM: public CBase |
|
55 { |
|
56 public: |
|
57 /** |
|
58 Creates an instance of CXmlEngDeserializerDOM. |
|
59 @return The DOM deserializer instance |
|
60 @leave KErrNoMemory Memory allocation failure |
|
61 */ |
|
62 IMPORT_C static CXmlEngDeserializerDOM* NewL(); |
|
63 |
|
64 /** |
|
65 Sets the input type to file and saves the file name for later |
|
66 deserialization. |
|
67 @param aFileName The file name of the file to deserialize |
|
68 @param aType The deserialization format |
|
69 @leave - One of the system-wide error codes |
|
70 */ |
|
71 IMPORT_C void SetInputFileL(const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault); |
|
72 |
|
73 /** |
|
74 Sets the input to to buffer and saves the buffer for later deserialization. |
|
75 @param aBuffer The buffer to deserialize |
|
76 @param aType The deserialization format |
|
77 */ |
|
78 IMPORT_C void SetInputBuffer(const TDesC8& aBuffer, TXmlEngDeserializerType aType = EDeserializerDefault); |
|
79 |
|
80 /** |
|
81 Sets a list of data containers and indicates that the XML to be |
|
82 deserialized contains references (such as xop:include) to data stored |
|
83 outside the DOM tree. |
|
84 |
|
85 Upon deserialization, the references are substituted with the matching data |
|
86 containers and returned via the content handler. |
|
87 |
|
88 This often occurs when a multipart MIME message is received. The text XML |
|
89 content may be in one part, while the binary content is in another part. |
|
90 Each part containing binary content must be placed into a data container using |
|
91 RXmlEngDocument::CreateBinaryContainerL() or similar. When deserialization |
|
92 of the XML occurs, the data containers are retrieved by content-id. |
|
93 |
|
94 Ownership is not transferred and the list must stay in scope for the |
|
95 lifetime of the deserializer. |
|
96 |
|
97 @param aList The list of data containers |
|
98 @leave - Any system-wide error code |
|
99 */ |
|
100 IMPORT_C void UseExternalDataL(RArray<TXmlEngDataContainer>& aList); |
|
101 |
|
102 /** |
|
103 Gets the list of external data containers. |
|
104 @return The list of data containers or NULL if no external data is registered |
|
105 */ |
|
106 IMPORT_C RArray<TXmlEngDataContainer>* ExternalData(); |
|
107 |
|
108 /** |
|
109 Sets the DOM implementation that will be used to create the DOM tree |
|
110 @param aImpl The DOM implementation |
|
111 @leave - Does not leave |
|
112 */ |
|
113 IMPORT_C void UseDOMImplementationL(RXmlEngDOMImplementation& aImpl); |
|
114 |
|
115 /** |
|
116 Deserializes the file or buffer previously set by SetInputFileL() or |
|
117 SetInputBuffer() and creates a new document that holds the DOM tree. |
|
118 |
|
119 @return The document that holds the DOM tree |
|
120 @leave KXmlEngErrNoParameters No file or buffer has been previously set |
|
121 @leave KXmlEngErrWrongUseOfAPI DOM Implementation not set |
|
122 @leave - One of the system-wide error codes |
|
123 */ |
|
124 IMPORT_C RXmlEngDocument DeserializeL(); |
|
125 |
|
126 /** |
|
127 Deserializes the given file and creates a new document that holds the DOM |
|
128 tree. Any filename previously set with SetInputFileL() is ignored. |
|
129 |
|
130 @param aFileName The file to be deserialized |
|
131 @param aType The deserialization format |
|
132 @return The document that holds the DOM tree |
|
133 @leave KXmlEngErrWrongUseOfAPI DOM Implementation not set |
|
134 @leave - One of the system wide error codes |
|
135 */ |
|
136 IMPORT_C RXmlEngDocument DeserializeL( const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault); |
|
137 |
|
138 /** |
|
139 Deserializes the given file and creates a new document that holds the DOM |
|
140 tree. Any filename previously set with SetInputFileL() is ignored. |
|
141 |
|
142 @param aRFs File Server session |
|
143 @param aFileName The file to be deserialized |
|
144 @param aType The deserialization format |
|
145 @return The document that holds the DOM tree |
|
146 @leave KXmlEngErrWrongUseOfAPI DOM Implementation not set |
|
147 @leave - One of the system wide error codes |
|
148 */ |
|
149 IMPORT_C RXmlEngDocument DeserializeL( RFs& aRFs, const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault); |
|
150 |
|
151 /** |
|
152 Deserializes the given buffer and creates a new document that holds the DOM |
|
153 tree. Any buffer previously set with SetInputBuffer() is ignored. |
|
154 |
|
155 @param aBuffer Buffer to be parsed |
|
156 @param aType Input type |
|
157 @return The document that holds the DOM tree |
|
158 @leave KXmlEngErrWrongUseOfAPI DOM Implementation not set |
|
159 @leave - One of the system wide error codes |
|
160 */ |
|
161 IMPORT_C RXmlEngDocument DeserializeL( const TDesC8& aBuffer, TXmlEngDeserializerType aType = EDeserializerDefault); |
|
162 |
|
163 /** Destructor. */ |
|
164 ~CXmlEngDeserializerDOM(); |
|
165 |
|
166 protected: |
|
167 /** Default constructor. */ |
|
168 CXmlEngDeserializerDOM(); |
|
169 |
|
170 protected: |
|
171 /** File to be parsed */ |
|
172 HBufC* iInputFileName; |
|
173 /** Buffer to be parsed */ |
|
174 TPtrC8 iBuffer; |
|
175 /** Array of external data */ |
|
176 RArray<TXmlEngDataContainer>* iDataList; |
|
177 /** Deserializer type */ |
|
178 TXmlEngDeserializerType iType; |
|
179 /** DOM implementation */ |
|
180 RXmlEngDOMImplementation* iImpl; |
|
181 |
|
182 }; //class CXmlEngDeserializerDOM |
|
183 |
|
184 #endif /* XMLENGDESERIALIZERDOM_H */ |
|
185 |