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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // XML Deserializer to DOM tree
24 #ifndef XMLENGDESERIALIZERDOM_H
25 #define XMLENGDESERIALIZERDOM_H
27 #include <xml/dom/xmlengdeserializer.h>
34 class RXmlEngDOMImplementation;
35 class RXmlEngDocument;
38 Deserializes a XML file to a DOM tree.
40 Sample code for deserialization to a DOM tree:
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);
50 RXmlEngDocument doc = deserializer->DeserializeL();
51 CleanupStack::PopAndDestroy();// deserializer
54 class CXmlEngDeserializerDOM: public CBase
58 Creates an instance of CXmlEngDeserializerDOM.
59 @return The DOM deserializer instance
60 @leave KErrNoMemory Memory allocation failure
62 IMPORT_C static CXmlEngDeserializerDOM* NewL();
65 Sets the input type to file and saves the file name for later
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
71 IMPORT_C void SetInputFileL(const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault);
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
78 IMPORT_C void SetInputBuffer(const TDesC8& aBuffer, TXmlEngDeserializerType aType = EDeserializerDefault);
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
85 Upon deserialization, the references are substituted with the matching data
86 containers and returned via the content handler.
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.
94 Ownership is not transferred and the list must stay in scope for the
95 lifetime of the deserializer.
97 @param aList The list of data containers
98 @leave - Any system-wide error code
100 IMPORT_C void UseExternalDataL(RArray<TXmlEngDataContainer>& aList);
103 Gets the list of external data containers.
104 @return The list of data containers or NULL if no external data is registered
106 IMPORT_C RArray<TXmlEngDataContainer>* ExternalData();
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
113 IMPORT_C void UseDOMImplementationL(RXmlEngDOMImplementation& aImpl);
116 Deserializes the file or buffer previously set by SetInputFileL() or
117 SetInputBuffer() and creates a new document that holds the DOM tree.
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
124 IMPORT_C RXmlEngDocument DeserializeL();
127 Deserializes the given file and creates a new document that holds the DOM
128 tree. Any filename previously set with SetInputFileL() is ignored.
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
136 IMPORT_C RXmlEngDocument DeserializeL( const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault);
139 Deserializes the given file and creates a new document that holds the DOM
140 tree. Any filename previously set with SetInputFileL() is ignored.
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
149 IMPORT_C RXmlEngDocument DeserializeL( RFs& aRFs, const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault);
152 Deserializes the given buffer and creates a new document that holds the DOM
153 tree. Any buffer previously set with SetInputBuffer() is ignored.
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
161 IMPORT_C RXmlEngDocument DeserializeL( const TDesC8& aBuffer, TXmlEngDeserializerType aType = EDeserializerDefault);
164 ~CXmlEngDeserializerDOM();
167 /** Default constructor. */
168 CXmlEngDeserializerDOM();
171 /** File to be parsed */
172 HBufC* iInputFileName;
173 /** Buffer to be parsed */
175 /** Array of external data */
176 RArray<TXmlEngDataContainer>* iDataList;
177 /** Deserializer type */
178 TXmlEngDeserializerType iType;
179 /** DOM implementation */
180 RXmlEngDOMImplementation* iImpl;
182 }; //class CXmlEngDeserializerDOM
184 #endif /* XMLENGDESERIALIZERDOM_H */