|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * XEDOMEXAMPLE.H 00003 * Copyright (c) 2007 Nokia Corporation. 00004 * This material, including documentation and any related computer 00005 * programs,is protected by copyright controlled by Nokia Corporation. 00006 */ 00007 00008 00009 #ifndef XEDOMEXAMPLE_H 00010 #define XEDOMEXAMPLE_H 00011 00012 #include <e32test.h> 00013 #include <f32file.h> 00014 00015 //XmlEng headers 00016 #include <xmlengdom.h> 00017 #include <XmlEngErrors.h> 00018 00019 // Size of file path names used in this example 00020 const TInt KFilePathSize = 128; 00021 00022 /** 00023 * The XML Engine DOM Example Application Class 00024 */ 00025 00026 class CXEDomEx : public CBase 00027 { 00028 00029 public: 00030 00031 /** 00032 * High level Use cases demonstrated in this application 00033 */ 00034 enum TMenuItems 00035 { 00036 EQuit = 0, 00037 EParsing, 00038 ESave, 00039 EDocProcess, 00040 ENsProcess, 00041 EAttributes, 00042 EElements, 00043 EContainer 00044 }; 00045 00046 00047 /** 00048 * Construction functions 00049 */ 00050 virtual ~CXEDomEx(); 00051 static CXEDomEx* NewLC(); 00052 static CXEDomEx* NewL(); 00053 00054 /** 00055 * Function to start the application 00056 */ 00057 void StartExampleL(); 00058 00059 00060 /** 00061 * Main example functions 00062 */ 00063 00064 00065 /** 00066 * Demonstrates a simple parsing of an XML file and 00067 * return the document in tree form. Demonstrates 00068 * parsing a file as well as a buffer 00069 */ 00070 void ParseExampleL(); 00071 00072 /** 00073 * Demonstrates the saving 00074 * of an XML document onto 00075 * a given file or buffer 00076 */ 00077 void SaveExampleL(); 00078 00079 /** 00080 * Demonstrates the creation / buidling of a document from scratch. 00081 * Also shows how to deal with the different nodes 00082 * in the document and operations on a node list that can be done. 00083 */ 00084 void DocProcessingExampleL(); 00085 00086 /** 00087 * This example demonstrates how namespaces can be dealt 00088 * with in XML Engine DOM. It covers looking up for namespace 00089 * URIs, prefixes, retrieving the default namespace uris, 00090 * checking for NS URIs for a given prefix, creating a NS 00091 * prefix & URI, addding a NS declaration onto an element etc. 00092 */ 00093 void NsProcessingExampleL(); 00094 00095 /** 00096 * This example demonstrates how xml engine DOM deals 00097 * with attributes. It shows checking an element whether 00098 * it has an attribute, getting/setting attribute name/values, 00099 * adding/removing attributes, creating/deleting an attribute 00100 * node, copying attributes, attributes with namespaces etc. 00101 */ 00102 void AttributesExampleL(); 00103 00104 /** 00105 * This example deals with element class of XML engine DOM 00106 * It shows adding of new elements with/without namespaces, 00107 * creating elements with auto prefixes, removal of element 00108 * nodes, setting content text for elements (both raw and 00109 * escaped), fetching elements by their name, removing NS 00110 * declarations of an elements etc. 00111 */ 00112 void ElementsExampleL(); 00113 00114 00115 /** 00116 * This example demonstrates usage of internal (binary)& 00117 * external (chunk) data containers provided by XML engine 00118 * DOM. Creation of these containers, fetching the contents 00119 * of these containers, setting the contens of these containers, 00120 * specifying offsets,size in case of external containers, 00121 * getting the list of data containers for the document 00122 */ 00123 void DataContainersExampleL(); 00124 00125 00126 public: 00127 /** 00128 * Sub example functions 00129 *(Used by main example functions) 00130 */ 00131 00132 /** 00133 * Creating a new xml document from scratch 00134 */ 00135 void CreateDocumentL(); 00136 00137 /** 00138 * Perform some sibling operations, e.g. move around the position of sibling nodes 00139 */ 00140 void SiblingOperationsL(); 00141 00142 /** 00143 * Shows how to use NodeList class 00144 */ 00145 void NodeListOperationsL(); 00146 00147 /** 00148 * Perform basic operation of attributes, i.e. getting/setting their values, removing etc 00149 */ 00150 void AttributeOperationsL(); 00151 00152 /** 00153 * Shows how to add attributes in different ways 00154 */ 00155 void AddAttributesL(); 00156 00157 /** 00158 * Shows adding xml elements in different ways 00159 */ 00160 void AddRemoveElementsL(); 00161 00162 /** 00163 * Shows different ways of changing element's text 00164 */ 00165 void SetElementTextL(); 00166 00167 /** 00168 * Shows usage of internal binary containers within XML document tree 00169 */ 00170 void BinaryContainersL(); 00171 00172 /** 00173 * Shows usage of external binary containers i.e filec ontainers, 00174 * chunk containers, within XML document tree 00175 */ 00176 void ExternalContainersL(); 00177 00178 /** 00179 * Drive letter for input testdata 00180 */ 00181 TBuf<4> iDrive; 00182 00183 private: 00184 /** 00185 * Internal support functions 00186 */ 00187 CXEDomEx(const TDesC& aTestName); 00188 void ConstructL(); 00189 00190 /** 00191 * Retrieves the installation drive letter and stores for future use, 00192 * required for filepath names for test input/output files. 00193 */ 00194 void CXEDomEx::GetDriveLetterL(); 00195 00196 /** 00197 * Used to present the user with a list of options (ourPrompt), 00198 * and get their selection. The user selection is validated against 00199 * the choices (validChoices) 00200 */ 00201 TInt GetSelection(const TDesC& ourPrompt, const TDesC& validChoices); 00202 00203 /** 00204 * Displays the message "Press any key..." on screen and waits for any key press 00205 * from user. 00206 */ 00207 void PressAnyKey(); 00208 00209 /** 00210 * Reads the file contents from given file and returns the contents in heap buffer 00211 */ 00212 static HBufC8* ReadFileL(const TDesC& aFileName); 00213 00214 // application console window 00215 RTest iTest; 00216 00217 // DOM Implementation, needed for initializing XmlEngine library once 00218 RXmlEngDOMImplementation iDomImpl; 00219 00220 // The DOM Parser, used for parsing documents 00221 RXmlEngDOMParser iDomParser; 00222 }; 00223 00224 00225 #endif // #ifndef XEDOMEXAMPLE_H
|
© Nokia 2009 |