williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@2
|
5 |
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@2
|
7 |
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: Document node functions
|
williamr@2
|
15 |
*
|
williamr@2
|
16 |
*/
|
williamr@2
|
17 |
|
williamr@2
|
18 |
|
williamr@2
|
19 |
|
williamr@2
|
20 |
|
williamr@2
|
21 |
|
williamr@2
|
22 |
|
williamr@2
|
23 |
#ifndef XMLENGINE_DOCUMENT_H_INCLUDED
|
williamr@2
|
24 |
#define XMLENGINE_DOCUMENT_H_INCLUDED
|
williamr@2
|
25 |
|
williamr@2
|
26 |
#include <f32file.h>
|
williamr@2
|
27 |
|
williamr@2
|
28 |
#include "xmlengnode.h"
|
williamr@2
|
29 |
#include "xmlengserializationoptions.h"
|
williamr@2
|
30 |
|
williamr@2
|
31 |
// FORWARD DECLARATION
|
williamr@2
|
32 |
class RXmlEngDOMImplementation;
|
williamr@2
|
33 |
|
williamr@2
|
34 |
/**
|
williamr@2
|
35 |
* Instance of RXmlEngDocument class represents an XML document in the DOM tree.
|
williamr@2
|
36 |
*
|
williamr@2
|
37 |
* Is a storage all nodes and information about XML data.
|
williamr@2
|
38 |
*
|
williamr@2
|
39 |
* @lib XmlEngineDOM.lib
|
williamr@2
|
40 |
* @since S60 v3.1
|
williamr@2
|
41 |
*/
|
williamr@2
|
42 |
class RXmlEngDocument : public TXmlEngNode
|
williamr@2
|
43 |
{
|
williamr@2
|
44 |
public:
|
williamr@2
|
45 |
/**
|
williamr@2
|
46 |
* Default constructor.
|
williamr@2
|
47 |
*
|
williamr@2
|
48 |
* Instance of RXmlEngDocument must be "opened" with one of OpenL() overloads.
|
williamr@2
|
49 |
*
|
williamr@2
|
50 |
* @since S60 v3.1
|
williamr@2
|
51 |
*/
|
williamr@2
|
52 |
IMPORT_C RXmlEngDocument();
|
williamr@2
|
53 |
|
williamr@2
|
54 |
/**
|
williamr@2
|
55 |
* Opens the document.
|
williamr@2
|
56 |
*
|
williamr@2
|
57 |
* @since S60 v3.2
|
williamr@2
|
58 |
* @param aDOMImpl DOM implementation object
|
williamr@2
|
59 |
* @return KErrNone if succeed.
|
williamr@2
|
60 |
*/
|
williamr@2
|
61 |
IMPORT_C void OpenL(RXmlEngDOMImplementation& aDOMImpl);
|
williamr@2
|
62 |
|
williamr@2
|
63 |
/**
|
williamr@2
|
64 |
* Opens the document.
|
williamr@2
|
65 |
*
|
williamr@2
|
66 |
* @since S60 v3.2
|
williamr@2
|
67 |
* @param aDOMImpl DOM implementation object
|
williamr@2
|
68 |
* @param aInternal Document pointer
|
williamr@2
|
69 |
* @return KErrNone if succeed.
|
williamr@2
|
70 |
*/
|
williamr@2
|
71 |
IMPORT_C void OpenL(RXmlEngDOMImplementation& aDOMImpl, void* aInternal);
|
williamr@2
|
72 |
|
williamr@2
|
73 |
/**
|
williamr@2
|
74 |
* Opens the document.
|
williamr@2
|
75 |
*
|
williamr@2
|
76 |
* @since S60 v3.2
|
williamr@2
|
77 |
* @param aDOMImpl DOM implementation object
|
williamr@2
|
78 |
* @param aRoot element taht will be root of the DOM tree
|
williamr@2
|
79 |
* @return KErrNone if succeed.
|
williamr@2
|
80 |
*/
|
williamr@2
|
81 |
IMPORT_C void OpenL(RXmlEngDOMImplementation& aDOMImpl, TXmlEngElement aRoot);
|
williamr@2
|
82 |
|
williamr@2
|
83 |
/**
|
williamr@2
|
84 |
* Closes document
|
williamr@2
|
85 |
*
|
williamr@2
|
86 |
* @since S60 v3.1
|
williamr@2
|
87 |
*/
|
williamr@2
|
88 |
IMPORT_C void Close();
|
williamr@2
|
89 |
|
williamr@2
|
90 |
/**
|
williamr@2
|
91 |
* Serializes document tree into a file. For nodes containing binary data in the form of BinaryDataContainer,
|
williamr@2
|
92 |
* FileContainer or ChunkContainer, client can implement custom serialization by implementing the interface
|
williamr@2
|
93 |
* MXmlEngDataSerializer and specify the pointer in iDataSerializer member of aSaveOptions parameter. If no
|
williamr@2
|
94 |
* custom serialization is specified, the binary data container nodes are serialized like text nodes.
|
williamr@2
|
95 |
*
|
williamr@2
|
96 |
* @since S60 v3.2
|
williamr@2
|
97 |
* @param aFileName A file name (with path)
|
williamr@2
|
98 |
* @param aRoot Root node to be serialized
|
williamr@2
|
99 |
* @param aSaveOptions Options that control how serialization is performed
|
williamr@2
|
100 |
* @return Number of byte written
|
williamr@2
|
101 |
* @leave KErrNoMemory, KErrGeneral, KXmlEngErrWrongEncoding, KErrDiskFull.
|
williamr@2
|
102 |
*/
|
williamr@2
|
103 |
IMPORT_C TInt SaveL( const TDesC& aFileName,
|
williamr@2
|
104 |
TXmlEngNode aRoot = TXmlEngNode(),
|
williamr@2
|
105 |
const TXmlEngSerializationOptions& aSaveOptions = TXmlEngSerializationOptions() ) const;
|
williamr@2
|
106 |
|
williamr@2
|
107 |
/**
|
williamr@2
|
108 |
* Serializes document tree into a file. For nodes containing binary data in the form of BinaryDataContainer,
|
williamr@2
|
109 |
* FileContainer or ChunkContainer, client can implement custom serialization by implementing the interface
|
williamr@2
|
110 |
* MXmlEngDataSerializer and specify the pointer in iDataSerializer member of aSaveOptions parameter. If no
|
williamr@2
|
111 |
* custom serialization is specified, the binary data container nodes are serialized like text nodes.
|
williamr@2
|
112 |
*
|
williamr@2
|
113 |
* @since S60 v3.2
|
williamr@2
|
114 |
* @param aRFs File Server session
|
williamr@2
|
115 |
* @param aFileName A file name (with path)
|
williamr@2
|
116 |
* @param aRoot Root node to be serialized
|
williamr@2
|
117 |
* @param aSaveOptions Options that control how serialization is performed
|
williamr@2
|
118 |
* @return Number of byte written
|
williamr@2
|
119 |
* @leave KErrNoMemory, KErrGeneral, KXmlEngErrWrongEncoding, KErrDiskFull.
|
williamr@2
|
120 |
*/
|
williamr@2
|
121 |
IMPORT_C TInt SaveL( RFs& aRFs,
|
williamr@2
|
122 |
const TDesC& aFileName,
|
williamr@2
|
123 |
TXmlEngNode aRoot = TXmlEngNode(),
|
williamr@2
|
124 |
const TXmlEngSerializationOptions& aSaveOptions = TXmlEngSerializationOptions() ) const;
|
williamr@2
|
125 |
|
williamr@2
|
126 |
/**
|
williamr@2
|
127 |
* Serializes a document tree into provided output stream, which supports progressive writing of data.
|
williamr@2
|
128 |
* For nodes containing binary data in the form of BinaryDataContainer, FileContainer or ChunkContainer,
|
williamr@2
|
129 |
* client can implement custom serialization by implementing the interface MXmlEngDataSerializer and specify
|
williamr@2
|
130 |
* the pointer in iDataSerializer member of aSaveOptions parameter. If no custom serialization is specified,
|
williamr@2
|
131 |
* the binary data container nodes are serialized like text nodes.
|
williamr@2
|
132 |
*
|
williamr@2
|
133 |
* @since S60 v3.1
|
williamr@2
|
134 |
* @param aStream An output stream to write serialized DOM tree
|
williamr@2
|
135 |
* @param aRoot Root node to be serialized
|
williamr@2
|
136 |
* @param aSaveOptions Options that control how serialization is performed
|
williamr@2
|
137 |
* @return Number of byte written
|
williamr@2
|
138 |
* @leave KXmlEngErrWrongUseOfAPI or one of general codes (e.g.KErrNoMemory)
|
williamr@2
|
139 |
* @see MXmlEngOutputStream
|
williamr@2
|
140 |
*/
|
williamr@2
|
141 |
IMPORT_C TInt SaveL( MXmlEngOutputStream& aStream,
|
williamr@2
|
142 |
TXmlEngNode aRoot = TXmlEngNode(),
|
williamr@2
|
143 |
const TXmlEngSerializationOptions& aSaveOptions = TXmlEngSerializationOptions() ) const;
|
williamr@2
|
144 |
|
williamr@2
|
145 |
/**
|
williamr@2
|
146 |
* Saves document tree into memory buffer
|
williamr@2
|
147 |
*
|
williamr@2
|
148 |
* @since S60 v3.1
|
williamr@2
|
149 |
* @param aBuffer Resulting buffer
|
williamr@2
|
150 |
* @param aRoot A "root" of the subtree to serialize
|
williamr@2
|
151 |
* @param aSaveOptions Various options to be effective during serialization
|
williamr@2
|
152 |
* @return Number of bytes in updated buffer
|
williamr@2
|
153 |
* @leave KErrNoMemory, KErrGeneral, KXmlEngErrWrongEncoding.
|
williamr@2
|
154 |
*
|
williamr@2
|
155 |
* @note Result returned via aBuffer argument owns the memory buffer; it is up to
|
williamr@2
|
156 |
* method caller to free it like in this sample:
|
williamr@2
|
157 |
*
|
williamr@2
|
158 |
* @see TXmlEngSerializationOptions
|
williamr@2
|
159 |
*/
|
williamr@2
|
160 |
IMPORT_C TInt SaveL(RBuf8& aBuffer,
|
williamr@2
|
161 |
TXmlEngNode aRoot = TXmlEngNode(),
|
williamr@2
|
162 |
const TXmlEngSerializationOptions& aSaveOptions = TXmlEngSerializationOptions()) const;
|
williamr@2
|
163 |
|
williamr@2
|
164 |
/**
|
williamr@2
|
165 |
* Creates complete copy of the document
|
williamr@2
|
166 |
*
|
williamr@2
|
167 |
* @since S60 v3.1
|
williamr@2
|
168 |
* @return Complete copy of the document tree
|
williamr@2
|
169 |
*/
|
williamr@2
|
170 |
IMPORT_C RXmlEngDocument CloneDocumentL() const;
|
williamr@2
|
171 |
|
williamr@2
|
172 |
/**
|
williamr@2
|
173 |
* Creates new element from specific namespace to be a root of the document tree.
|
williamr@2
|
174 |
* Any existing document element of the document is destroyed
|
williamr@2
|
175 |
*
|
williamr@2
|
176 |
* @since S60 v3.1
|
williamr@2
|
177 |
* @param aName Element name
|
williamr@2
|
178 |
* @param aNamespaceUri Element namespace URI
|
williamr@2
|
179 |
* @param aPrefix Element namemespace prefix
|
williamr@2
|
180 |
* @return A new root element
|
williamr@2
|
181 |
*/
|
williamr@2
|
182 |
IMPORT_C TXmlEngElement CreateDocumentElementL(const TDesC8& aName,
|
williamr@2
|
183 |
const TDesC8& aNamespaceUri = KNullDesC8,
|
williamr@2
|
184 |
const TDesC8& aPrefix = KNullDesC8);
|
williamr@2
|
185 |
|
williamr@2
|
186 |
/**
|
williamr@2
|
187 |
* Replaces (and destroys) document element with another one
|
williamr@2
|
188 |
* New document element is added as the last child to the document node
|
williamr@2
|
189 |
*
|
williamr@2
|
190 |
* @since S60 v3.1
|
williamr@2
|
191 |
* @param aNewDocElement New document tree
|
williamr@2
|
192 |
*
|
williamr@2
|
193 |
* @note Use TXmlEngElement::ReconcileNamespacesL() on the new document element
|
williamr@2
|
194 |
* if it or its descendants can contain references to namespace declarations
|
williamr@2
|
195 |
* out of the element
|
williamr@2
|
196 |
* @see TXmlEngElement::ReconcileNamespacesL()
|
williamr@2
|
197 |
*/
|
williamr@2
|
198 |
IMPORT_C void SetDocumentElement(TXmlEngElement aNewDocElement);
|
williamr@2
|
199 |
|
williamr@2
|
200 |
/**
|
williamr@2
|
201 |
* Get document encoding
|
williamr@2
|
202 |
*
|
williamr@2
|
203 |
* @since S60 v3.1
|
williamr@2
|
204 |
* @return Encoding of the source XML data.
|
williamr@2
|
205 |
*/
|
williamr@2
|
206 |
IMPORT_C TPtrC8 XmlEncoding() const;
|
williamr@2
|
207 |
|
williamr@2
|
208 |
/**
|
williamr@2
|
209 |
* Get xml version
|
williamr@2
|
210 |
*
|
williamr@2
|
211 |
* @since S60 v3.1
|
williamr@2
|
212 |
* @return Version number of XML taken from XML declaration
|
williamr@2
|
213 |
*/
|
williamr@2
|
214 |
IMPORT_C TPtrC8 XmlVersion() const;
|
williamr@2
|
215 |
|
williamr@2
|
216 |
/**
|
williamr@2
|
217 |
* Retrieves base URI (if defined) of the document or NULL
|
williamr@2
|
218 |
*
|
williamr@2
|
219 |
* @since S60 v3.1
|
williamr@2
|
220 |
* @return Document URI
|
williamr@2
|
221 |
*/
|
williamr@2
|
222 |
IMPORT_C TPtrC8 DocumentUri() const;
|
williamr@2
|
223 |
|
williamr@2
|
224 |
/**
|
williamr@2
|
225 |
* Check if document is standalone
|
williamr@2
|
226 |
*
|
williamr@2
|
227 |
* @since S60 v3.1
|
williamr@2
|
228 |
* @return Whether standalone="true" was specified in XML declaration in the source XML file.
|
williamr@2
|
229 |
*/
|
williamr@2
|
230 |
IMPORT_C TBool IsStandalone() const;
|
williamr@2
|
231 |
|
williamr@2
|
232 |
/**
|
williamr@2
|
233 |
* Sets XML version number to be shown in XML declaration when document is serialized.
|
williamr@2
|
234 |
*
|
williamr@2
|
235 |
* @since S60 v3.1
|
williamr@2
|
236 |
* @param aVersion New version
|
williamr@2
|
237 |
*/
|
williamr@2
|
238 |
IMPORT_C void SetXmlVersionL(const TDesC8& aVersion);
|
williamr@2
|
239 |
|
williamr@2
|
240 |
/**
|
williamr@2
|
241 |
* Sets location of the document.
|
williamr@2
|
242 |
* Document's URI is used as top-level base URI definition.
|
williamr@2
|
243 |
*
|
williamr@2
|
244 |
* @since S60 v3.1
|
williamr@2
|
245 |
* @param aUri New document URI
|
williamr@2
|
246 |
*/
|
williamr@2
|
247 |
IMPORT_C void SetDocumentUriL(const TDesC8& aUri);
|
williamr@2
|
248 |
|
williamr@2
|
249 |
/**
|
williamr@2
|
250 |
* Sets 'standalone' attribute of XML declaration for a document
|
williamr@2
|
251 |
*
|
williamr@2
|
252 |
* @since S60 v3.1
|
williamr@2
|
253 |
* @param aStandalone Is document standalone
|
williamr@2
|
254 |
*/
|
williamr@2
|
255 |
IMPORT_C void SetStandalone(TBool aStandalone);
|
williamr@2
|
256 |
|
williamr@2
|
257 |
/**
|
williamr@2
|
258 |
* Get dom implementation.
|
williamr@2
|
259 |
*
|
williamr@2
|
260 |
* @since S60 v3.1
|
williamr@2
|
261 |
* @return Object that represents current DOM implementation
|
williamr@2
|
262 |
*
|
williamr@2
|
263 |
* @note There is no practical use of implementation object in this version
|
williamr@2
|
264 |
* of API other than for creating new RXmlEngDocument instances, but
|
williamr@2
|
265 |
* it will change in the future, when an implementation object
|
williamr@2
|
266 |
* is used for changing configuration settings at run-time.
|
williamr@2
|
267 |
*/
|
williamr@2
|
268 |
IMPORT_C RXmlEngDOMImplementation Implementation() const;
|
williamr@2
|
269 |
|
williamr@2
|
270 |
/**
|
williamr@2
|
271 |
* Get document element
|
williamr@2
|
272 |
*
|
williamr@2
|
273 |
* @since S60 v3.1
|
williamr@2
|
274 |
* @return A document element - the top-most element in the document tree
|
williamr@2
|
275 |
*/
|
williamr@2
|
276 |
IMPORT_C TXmlEngElement DocumentElement() const;
|
williamr@2
|
277 |
|
williamr@2
|
278 |
/**
|
williamr@2
|
279 |
* Sets "document" property on the node and all its descendants to be this RXmlEngDocument node
|
williamr@2
|
280 |
*
|
williamr@2
|
281 |
* @since S60 v3.1
|
williamr@2
|
282 |
* @param aSource Node that should be added.
|
williamr@2
|
283 |
* @return Adopted node
|
williamr@2
|
284 |
*/
|
williamr@2
|
285 |
IMPORT_C TXmlEngNode AdoptNodeL(TXmlEngNode aSource);
|
williamr@2
|
286 |
|
williamr@2
|
287 |
/**
|
williamr@2
|
288 |
* Creates new attribute,
|
williamr@2
|
289 |
*
|
williamr@2
|
290 |
* @since S60 v3.1
|
williamr@2
|
291 |
* @param aName Name of the atribute; no prefix allowed
|
williamr@2
|
292 |
* @param aValue Value of the attribute (optional)
|
williamr@2
|
293 |
* @return Handler to the newly created attribute
|
williamr@2
|
294 |
*
|
williamr@2
|
295 |
* @note
|
williamr@2
|
296 |
* aValue should represent a correct value of an attribute if it is put as is into XML file
|
williamr@2
|
297 |
* (with all characters correctly escaped with entity references when XML spec requires)
|
williamr@2
|
298 |
*
|
williamr@2
|
299 |
* TXmlEngElement class provides a rich set of attribute creation methods, which not
|
williamr@2
|
300 |
* just create attribute but also link it into element.
|
williamr@2
|
301 |
*
|
williamr@2
|
302 |
* There is no way to create attributes with namespace (despite the DOM spec);
|
williamr@2
|
303 |
* you have to use one of the TXmlEngElement::AddNewAttributeL(..) methods instead
|
williamr@2
|
304 |
*
|
williamr@2
|
305 |
* Returned handler is the only reference to the allocated memory
|
williamr@2
|
306 |
* until you have attached the attribute to some element node
|
williamr@2
|
307 |
*/
|
williamr@2
|
308 |
IMPORT_C TXmlEngAttr CreateAttributeL(const TDesC8& aName,
|
williamr@2
|
309 |
const TDesC8& aValue = KNullDesC8);
|
williamr@2
|
310 |
|
williamr@2
|
311 |
/**
|
williamr@2
|
312 |
* Creates new text node and copies the content string into it.
|
williamr@2
|
313 |
*
|
williamr@2
|
314 |
* @since S60 v3.1
|
williamr@2
|
315 |
* @param aCharacters Text node content
|
williamr@2
|
316 |
* @return Created node
|
williamr@2
|
317 |
*/
|
williamr@2
|
318 |
IMPORT_C TXmlEngTextNode CreateTextNodeL(const TDesC8& aCharacters = KNullDesC8);
|
williamr@2
|
319 |
|
williamr@2
|
320 |
/**
|
williamr@2
|
321 |
* Creates new binary container and copies the content string into it.
|
williamr@2
|
322 |
* Pointer to the container is stored in the document's
|
williamr@2
|
323 |
* data container list that can be fetched using GetDataContainerList().
|
williamr@2
|
324 |
* @see GetDataContainerList( RArray<TXmlEngDataContainer>& aList )
|
williamr@2
|
325 |
*
|
williamr@2
|
326 |
* @since S60 v3.2
|
williamr@2
|
327 |
* @param aCid Content identifier
|
williamr@2
|
328 |
* @param aData Binary octets
|
williamr@2
|
329 |
* @return Created node
|
williamr@2
|
330 |
*/
|
williamr@2
|
331 |
IMPORT_C TXmlEngBinaryContainer CreateBinaryContainerL( const TDesC8& aCid,
|
williamr@2
|
332 |
const TDesC8& aData );
|
williamr@2
|
333 |
|
williamr@2
|
334 |
/**
|
williamr@2
|
335 |
* Creates new chunk container that stores reference to
|
williamr@2
|
336 |
* memory chunk.
|
williamr@2
|
337 |
* Pointer to the container is stored in the document's
|
williamr@2
|
338 |
* data container list that can be fetched using GetDataContainerList().
|
williamr@2
|
339 |
* @see GetDataContainerList( RArray<TXmlEngDataContainer>& aList )
|
williamr@2
|
340 |
*
|
williamr@2
|
341 |
* @since S60 v3.2
|
williamr@2
|
342 |
* @param aCid Content identifier
|
williamr@2
|
343 |
* @param aChunk RChunk reference
|
williamr@2
|
344 |
* @param aChunkOffset Offset to the binary data in aChunk
|
williamr@2
|
345 |
* @param aDataSize Size of binary data in aChunk
|
williamr@2
|
346 |
* @return Created node
|
williamr@2
|
347 |
*/
|
williamr@2
|
348 |
IMPORT_C TXmlEngChunkContainer CreateChunkContainerL( const TDesC8& aCid,
|
williamr@2
|
349 |
const RChunk& aChunk,
|
williamr@2
|
350 |
const TInt aChunkOffset,
|
williamr@2
|
351 |
const TInt aDataSize );
|
williamr@2
|
352 |
|
williamr@2
|
353 |
/**
|
williamr@2
|
354 |
* Creates new file container that stores reference to
|
williamr@2
|
355 |
* file in file system.
|
williamr@2
|
356 |
* Pointer to the container is stored in the document's
|
williamr@2
|
357 |
* data container list that can be fetched using GetDataContainerList().
|
williamr@2
|
358 |
* @see GetDataContainerList( RArray<TXmlEngDataContainer>& aList )
|
williamr@2
|
359 |
*
|
williamr@2
|
360 |
* @since S60 v3.2
|
williamr@2
|
361 |
* @param aCid Content identifier
|
williamr@2
|
362 |
* @param aFile RFile reference
|
williamr@2
|
363 |
* @return Created node
|
williamr@2
|
364 |
*/
|
williamr@2
|
365 |
IMPORT_C TXmlEngFileContainer CreateFileContainerL( const TDesC8& aCid,
|
williamr@2
|
366 |
const RFile& aFile );
|
williamr@2
|
367 |
|
williamr@2
|
368 |
/**
|
williamr@2
|
369 |
* Creates new element node that belongs to specific namespace.
|
williamr@2
|
370 |
* A namespace declaration node is created on the element.
|
williamr@2
|
371 |
*
|
williamr@2
|
372 |
* @since S60 v3.1
|
williamr@2
|
373 |
* @param aNamespaceUri Namespace of new element
|
williamr@2
|
374 |
* @param aPrefix Prefix to use for namespace binding and QName of the element
|
williamr@2
|
375 |
* @param aLocalName Local name of the element
|
williamr@2
|
376 |
* @return Created node
|
williamr@2
|
377 |
* @note If null namespace uri is provided element will be created without namespace.
|
williamr@2
|
378 |
*/
|
williamr@2
|
379 |
IMPORT_C TXmlEngElement CreateElementL(const TDesC8& aLocalName,
|
williamr@2
|
380 |
const TDesC8& aNamespaceUri = KNullDesC8,
|
williamr@2
|
381 |
const TDesC8& aPrefix = KNullDesC8);
|
williamr@2
|
382 |
|
williamr@2
|
383 |
/**
|
williamr@2
|
384 |
* Creates new comment node and copies the content string into it.
|
williamr@2
|
385 |
*
|
williamr@2
|
386 |
* @since S60 v3.1
|
williamr@2
|
387 |
* @param aText New comment
|
williamr@2
|
388 |
* @return Created node
|
williamr@2
|
389 |
*/
|
williamr@2
|
390 |
IMPORT_C TXmlEngComment CreateCommentL(const TDesC8& aText = KNullDesC8);
|
williamr@2
|
391 |
|
williamr@2
|
392 |
/**
|
williamr@2
|
393 |
* Creates new CDATA section node and copies the content into it.
|
williamr@2
|
394 |
*
|
williamr@2
|
395 |
* @since S60 v3.1
|
williamr@2
|
396 |
* @param aContents CDATASection content
|
williamr@2
|
397 |
* @return Created node
|
williamr@2
|
398 |
*/
|
williamr@2
|
399 |
IMPORT_C TXmlEngCDATASection CreateCDATASectionL(const TDesC8& aContents = KNullDesC8);
|
williamr@2
|
400 |
|
williamr@2
|
401 |
/**
|
williamr@2
|
402 |
* Creates new entity reference node for aEntityName entity
|
williamr@2
|
403 |
*
|
williamr@2
|
404 |
* @since S60 v3.1
|
williamr@2
|
405 |
* @param aEntityRef is a string in one of the forms:
|
williamr@2
|
406 |
* - <i>name</i>
|
williamr@2
|
407 |
* - <b>&</b><i>name</i>
|
williamr@2
|
408 |
* - <b>&</b><i>name</i><b>;</b>
|
williamr@2
|
409 |
* where <i>name</i> is the name of the entity
|
williamr@2
|
410 |
* @return Created node
|
williamr@2
|
411 |
*
|
williamr@2
|
412 |
* @note < , > , ' , " and other <b>predefined</b> entity references
|
williamr@2
|
413 |
* should not be created with this method. These entity refs are rather
|
williamr@2
|
414 |
* "character references" and encoded/decoded automatically.
|
williamr@2
|
415 |
*/
|
williamr@2
|
416 |
IMPORT_C TXmlEngEntityReference CreateEntityReferenceL(const TDesC8& aEntityRef);
|
williamr@2
|
417 |
|
williamr@2
|
418 |
/**
|
williamr@2
|
419 |
* Creates new processing instruction node and set its "target" and "data" values
|
williamr@2
|
420 |
*
|
williamr@2
|
421 |
* @since S60 v3.1
|
williamr@2
|
422 |
* @param aTarget Target
|
williamr@2
|
423 |
* @param aData Data
|
williamr@2
|
424 |
* @return Created node
|
williamr@2
|
425 |
*/
|
williamr@2
|
426 |
IMPORT_C TXmlEngProcessingInstruction CreateProcessingInstructionL(const TDesC8& aTarget,
|
williamr@2
|
427 |
const TDesC8& aData = KNullDesC8);
|
williamr@2
|
428 |
|
williamr@2
|
429 |
/**
|
williamr@2
|
430 |
* Registers specified attribute as xml:id.
|
williamr@2
|
431 |
* First parametr allows user, to specify sub-tree, not to search whole document.
|
williamr@2
|
432 |
* To search whole tree see @see RegisterXmlId(const TDesC8,const TDesC8)
|
williamr@2
|
433 |
*
|
williamr@2
|
434 |
* @since S60 v3.2
|
williamr@2
|
435 |
* @param aStartElement Root of tree to search (should be part of the document)
|
williamr@2
|
436 |
* @param aLocalName Name of attribute
|
williamr@2
|
437 |
* @param aNamespaceUri Namespace of new element (default empty)
|
williamr@2
|
438 |
*/
|
williamr@2
|
439 |
IMPORT_C void RegisterXmlIdL(TXmlEngElement aStartElement,
|
williamr@2
|
440 |
const TDesC8& aLocalName,
|
williamr@2
|
441 |
const TDesC8& aNamespaceUri = KNullDesC8);
|
williamr@2
|
442 |
|
williamr@2
|
443 |
/**
|
williamr@2
|
444 |
* Registers specified attribute as xml:id.
|
williamr@2
|
445 |
* Not to search whole tree see @see RegisterXmlId(TXmlEngElement,const TDesC8,const TDesC8)
|
williamr@2
|
446 |
*
|
williamr@2
|
447 |
* @since S60 v3.2
|
williamr@2
|
448 |
* @param aLocalName Name of attribute
|
williamr@2
|
449 |
* @param aNamespaceUri Namespace of new element (default empty)
|
williamr@2
|
450 |
*/
|
williamr@2
|
451 |
IMPORT_C void RegisterXmlIdL(const TDesC8& aLocalName,
|
williamr@2
|
452 |
const TDesC8& aNamespaceUri = KNullDesC8);
|
williamr@2
|
453 |
|
williamr@2
|
454 |
/**
|
williamr@2
|
455 |
* Looks for element with specified value of xml:id
|
williamr@2
|
456 |
*
|
williamr@2
|
457 |
* @since S60 v3.2
|
williamr@2
|
458 |
* @param aValue Name of attribute
|
williamr@2
|
459 |
* @return found element or null-element.
|
williamr@2
|
460 |
*/
|
williamr@2
|
461 |
IMPORT_C TXmlEngElement FindElementByXmlIdL(const TDesC8& aValue ) const;
|
williamr@2
|
462 |
|
williamr@2
|
463 |
/**
|
williamr@2
|
464 |
* Retrieves an array of data containers owned by this document.
|
williamr@2
|
465 |
*
|
williamr@2
|
466 |
* @note The document ceases to be the owner of data container when data container
|
williamr@2
|
467 |
* (or one of its predecessors) is removed from the document or data container
|
williamr@2
|
468 |
* (or one of its predecessors) becomes a part of another document.
|
williamr@2
|
469 |
* Unlinking data container (or one of its predecessors) doesn't remove
|
williamr@2
|
470 |
* ownership of data container from the this document so the list might
|
williamr@2
|
471 |
* contain containers that are not linked to this document anymore.
|
williamr@2
|
472 |
* @since S60 v3.2
|
williamr@2
|
473 |
* @param aList Array of data containers
|
williamr@2
|
474 |
*/
|
williamr@2
|
475 |
IMPORT_C void GetDataContainerList( RArray<TXmlEngDataContainer>& aList );
|
williamr@2
|
476 |
|
williamr@2
|
477 |
protected:
|
williamr@2
|
478 |
friend class RXmlEngDOMParser;
|
williamr@2
|
479 |
friend class TXmlEngNode;
|
williamr@2
|
480 |
friend class TXmlEngAttr;
|
williamr@2
|
481 |
friend class TXmlEngElement;
|
williamr@2
|
482 |
friend class RXmlEngDOMImplementation;
|
williamr@2
|
483 |
|
williamr@2
|
484 |
protected:
|
williamr@2
|
485 |
/**
|
williamr@2
|
486 |
* Constructor
|
williamr@2
|
487 |
*
|
williamr@2
|
488 |
* @since S60 v3.1
|
williamr@2
|
489 |
* @param aInternal Document pointer
|
williamr@2
|
490 |
*/
|
williamr@2
|
491 |
inline RXmlEngDocument(void* aInternal);
|
williamr@2
|
492 |
|
williamr@2
|
493 |
/**
|
williamr@2
|
494 |
* DISABLED for document; CloneDocumentL() must be used
|
williamr@2
|
495 |
*
|
williamr@2
|
496 |
* @since S60 v3.1
|
williamr@2
|
497 |
*/
|
williamr@2
|
498 |
inline TXmlEngNode CopyL() const;
|
williamr@2
|
499 |
|
williamr@2
|
500 |
/**
|
williamr@2
|
501 |
* DISABLED for document; Destroy() must be used
|
williamr@2
|
502 |
*
|
williamr@2
|
503 |
* @since S60 v3.1
|
williamr@2
|
504 |
*/
|
williamr@2
|
505 |
inline void Remove();
|
williamr@2
|
506 |
|
williamr@2
|
507 |
/**
|
williamr@2
|
508 |
* DISABLED for document; Destroy() must be used
|
williamr@2
|
509 |
*
|
williamr@2
|
510 |
* @since S60 v3.1
|
williamr@2
|
511 |
*/
|
williamr@2
|
512 |
inline void ReplaceWith(TXmlEngNode aNode);
|
williamr@2
|
513 |
private:
|
williamr@2
|
514 |
/**
|
williamr@2
|
515 |
* Main implementation of SaveL() functions that puts together all common code
|
williamr@2
|
516 |
* and serializes to buffer or output stream.
|
williamr@2
|
517 |
*
|
williamr@2
|
518 |
* @since S60 v3.2
|
williamr@2
|
519 |
* @param aNode Root node to be serialized
|
williamr@2
|
520 |
* @param aBuffer buffer with serialized data.
|
williamr@2
|
521 |
* @param aOutputStream stream that should be used during serialization
|
williamr@2
|
522 |
* @param aSaveOptions Options that control how serialization is performed
|
williamr@2
|
523 |
* @return Number of bytes written
|
williamr@2
|
524 |
* @leave KErrNoMemory, KErrGeneral, KXmlEngErrWrongEncoding, KErrDiskFull.
|
williamr@2
|
525 |
*/
|
williamr@2
|
526 |
TInt SaveNodeL( TXmlEngNode aNode,
|
williamr@2
|
527 |
RBuf8& aBuffer,
|
williamr@2
|
528 |
MXmlEngOutputStream* aOutputStream = NULL,
|
williamr@2
|
529 |
TXmlEngSerializationOptions aOpt = TXmlEngSerializationOptions()) const;
|
williamr@2
|
530 |
|
williamr@2
|
531 |
/**
|
williamr@2
|
532 |
* "Secondary" constructor that should be called on every newly created document node.
|
williamr@2
|
533 |
* Initializes container for nodes owned by the document.
|
williamr@2
|
534 |
*
|
williamr@2
|
535 |
* The need for such secondary constructor is in the fact that underlying libxml2
|
williamr@2
|
536 |
* library knows nothing about ownership of unlinked nodes -- this feature is
|
williamr@2
|
537 |
* implemented in C++ DOM wrapper.
|
williamr@2
|
538 |
*
|
williamr@2
|
539 |
* @since S60 v3.1
|
williamr@2
|
540 |
*/
|
williamr@2
|
541 |
void InitOwnedNodeListL();
|
williamr@2
|
542 |
|
williamr@2
|
543 |
/**
|
williamr@2
|
544 |
* Adds aNode to the list of owned nodes - the nodes that are not linked yet into a
|
williamr@2
|
545 |
* document tree, but still destroyed with the document that owns them.
|
williamr@2
|
546 |
*
|
williamr@2
|
547 |
* @since S60 v3.1
|
williamr@2
|
548 |
* @param aNode Node that should be added to document
|
williamr@2
|
549 |
*
|
williamr@2
|
550 |
* In case of OOM (during growing node list container) the argument node is freed with
|
williamr@2
|
551 |
* xmlFreeNode()
|
williamr@2
|
552 |
*/
|
williamr@2
|
553 |
void TakeOwnership(TXmlEngNode aNode);
|
williamr@2
|
554 |
|
williamr@2
|
555 |
/**
|
williamr@2
|
556 |
* Remove aNode from the list of owned nodes.
|
williamr@2
|
557 |
*
|
williamr@2
|
558 |
* @since S60 v3.1
|
williamr@2
|
559 |
* @param aNode Node that should be removed from document
|
williamr@2
|
560 |
*/
|
williamr@2
|
561 |
void RemoveOwnership(TXmlEngNode aNode);
|
williamr@2
|
562 |
|
williamr@2
|
563 |
protected:
|
williamr@2
|
564 |
/** Pointer to DOM implementation object */
|
williamr@2
|
565 |
RXmlEngDOMImplementation* iImpl;
|
williamr@2
|
566 |
|
williamr@2
|
567 |
};// class RXmlEngDocument
|
williamr@2
|
568 |
|
williamr@2
|
569 |
|
williamr@2
|
570 |
|
williamr@2
|
571 |
#include "xmlengdocument.inl"
|
williamr@2
|
572 |
|
williamr@2
|
573 |
#endif /* XMLENGINE_DOCUMENT_H_INCLUDED */
|