secureswitools/swisistools/source/interpretsislib/xmlgenerator.cpp
changeset 60 245df5276b97
parent 25 98b66e4fb0be
child 67 3a625661d1ce
--- a/secureswitools/swisistools/source/interpretsislib/xmlgenerator.cpp	Tue Jul 06 14:23:31 2010 +0300
+++ b/secureswitools/swisistools/source/interpretsislib/xmlgenerator.cpp	Wed Aug 18 09:55:45 2010 +0300
@@ -23,10 +23,13 @@
  @internalTechnology
 */
 
+#include "util.h"
 #include "xmlgenerator.h"
-#include "../common/exception.h"
+#include "exception.h"
 #include "is_utils.h"
 
+#include "utf8_wrapper.h"
+
 #include <xercesc/dom/DOM.hpp>
 #include <xercesc/util/XMLString.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
@@ -55,9 +58,135 @@
 typedef void (*xmlPlatform) ();
 typedef void (*releaseXmlChPtr) (XMLCh** buf);
 
-// constants used for writing to the xml file
-std::wstring	PreProvisionInformation(L"PreProvisionInformation");
-std::wstring	SoftwareTypeName(L"SoftwareTypeName");
+
+//------------------------------------- Literals ------------------------------------------
+// Xerces literals are of type XMLCh*. For gcc XMLCh is defined as unsigned short (UCS16). 
+// In windows wchar_t has the same size as XMLCh therefor literals defined as L"This is a 
+// literal" will work. But in linux size of wchar_t is 4 (UCS32) bytes and hence L cannot 
+// be used for defining literals. To avoid string conversion and dynamic memory allocation 
+// following method is used to represent unsigned short literal. Current compiler has the 
+// limitation to represent such literals.
+//-----------------------------------------------------------------------------------------
+const XMLCh* KPreProvisionInformation = (const XMLCh*)    "P\0r\0e\0P\0r\0o\0v\0i\0s\0i\0o\0n\0I\0n\0f\0o\0r\0m\0a\0t\0i\0o\0n\0\0\0";
+const XMLCh* KSoftwareTypeName = (const XMLCh*)           "S\0o\0f\0t\0w\0a\0r\0e\0T\0y\0p\0e\0N\0a\0m\0e\0\0\0";
+const XMLCh* KUTF16 = (const XMLCh*)                      "U\0T\0F\0-\0001\0006\0\0\0";
+const XMLCh* KComponent = (const XMLCh*)                  "C\0o\0m\0p\0o\0n\0e\0n\0t\0\0\0";
+const XMLCh* KDependentId = (const XMLCh*)                "D\0e\0p\0e\0n\0d\0e\0n\0t\0I\0d\0\0\0"; 
+const XMLCh* KToVersion = (const XMLCh*)                  "T\0o\0V\0e\0r\0s\0i\0o\0n\0\0\0";
+const XMLCh* KFromVersion = (const XMLCh*)                "F\0r\0o\0m\0V\0e\0r\0s\0i\0o\0n\0\0\0";
+const XMLCh* KSupplierId = (const XMLCh*)                 "S\0u\0p\0p\0l\0i\0e\0r\0I\0d\0\0\0";
+const XMLCh* KName = (const XMLCh*)                       "N\0a\0m\0e\0\0\0";
+const XMLCh* KFileProperty_StrValue = (const XMLCh*)      "F\0i\0l\0e\0P\0r\0o\0p\0e\0r\0t\0y\0_\0S\0t\0r\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KFileProperty_IntValue = (const XMLCh*)      "F\0i\0l\0e\0P\0r\0o\0p\0e\0r\0t\0y\0_\0I\0n\0t\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KLocation = (const XMLCh*)                   "L\0o\0c\0a\0t\0i\0o\0n\0\0\0";
+const XMLCh* KComponentProperty_IsBinary = (const XMLCh*) "C\0o\0m\0p\0o\0n\0e\0n\0t\0P\0r\0o\0p\0e\0r\0t\0y\0_\0I\0s\0B\0i\0n\0a\0r\0y\0\0\0";
+const XMLCh* KComponentProperty_StrValue = (const XMLCh*) "C\0o\0m\0p\0o\0n\0e\0n\0t\0P\0r\0o\0p\0e\0r\0t\0y\0_\0S\0t\0r\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KComponentProperty_IntValue = (const XMLCh*) "C\0o\0m\0p\0o\0n\0e\0n\0t\0P\0r\0o\0p\0e\0r\0t\0y\0_\0I\0n\0t\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KComponentProperty_Locale = (const XMLCh*)   "C\0o\0m\0p\0o\0n\0e\0n\0t\0P\0r\0o\0p\0e\0r\0t\0y\0_\0L\0o\0c\0a\0l\0e\0\0\0";
+const XMLCh* KComponentLocalizable_Vendor=(const XMLCh*)  "C\0o\0m\0p\0o\0n\0e\0n\0t\0L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0_\0V\0e\0n\0d\0o\0r\0\0\0";
+const XMLCh* KComponentLocalizable_Name = (const XMLCh*)  "C\0o\0m\0p\0o\0n\0e\0n\0t\0L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0_\0N\0a\0m\0e\0\0\0";
+const XMLCh* KComponentLocalizable_Locale=(const XMLCh*)  "C\0o\0m\0p\0o\0n\0e\0n\0t\0L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0_\0L\0o\0c\0a\0l\0e\0\0\0";
+const XMLCh* KBuild = (const XMLCh*)                      "B\0u\0i\0l\0d\0\0\0";
+const XMLCh* KMinor = (const XMLCh*)                      "M\0i\0n\0o\0r\0\0\0";
+const XMLCh* KMajor = (const XMLCh*)                      "M\0a\0j\0o\0r\0\0\0";
+const XMLCh* KVersion = (const XMLCh*)                    "V\0e\0r\0s\0i\0o\0n\0\0\0"; 
+const XMLCh* KHidden = (const XMLCh*)                     "H\0i\0d\0d\0e\0n\0\0\0";
+const XMLCh* KOriginVerified = (const XMLCh*)             "O\0r\0i\0g\0i\0n\0V\0e\0r\0i\0f\0i\0e\0d\0\0\0";
+const XMLCh* KGlobalId = (const XMLCh*)                   "G\0l\0o\0b\0a\0l\0I\0d\0\0\0";
+const XMLCh* KScomoState = (const XMLCh*)                 "S\0c\0o\0m\0o\0S\0t\0a\0t\0e\0\0\0";
+const XMLCh* KSize = (const XMLCh*)                       "S\0i\0z\0e\0\0\0";
+const XMLCh* KRemovable = (const XMLCh*)                  "R\0e\0m\0o\0v\0a\0b\0l\0e\0\0\0";
+const XMLCh* KComponentLocalizable = (const XMLCh*)       "C\0o\0m\0p\0o\0n\0e\0n\0t\0L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0\0\0";
+const XMLCh* KComponentProperty = (const XMLCh*)          "C\0o\0m\0p\0o\0n\0e\0n\0t\0P\0r\0o\0p\0e\0r\0t\0y\0\0\0";
+const XMLCh* KComponentProperty_Value = (const XMLCh*)    "C\0o\0m\0p\0o\0n\0e\0n\0t\0P\0r\0o\0p\0e\0r\0t\0y\0_\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KComponentFile = (const XMLCh*)              "C\0o\0m\0p\0o\0n\0e\0n\0t\0F\0i\0l\0e\0\0\0";
+const XMLCh* KFileProperty = (const XMLCh*)               "F\0i\0l\0e\0P\0r\0o\0p\0e\0r\0t\0y\0\0\0";
+const XMLCh* KFileProperty_Value = (const XMLCh*)         "F\0i\0l\0e\0P\0r\0o\0p\0e\0r\0t\0y\0_\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KComponentDependency = (const XMLCh*)        "C\0o\0m\0p\0o\0n\0e\0n\0t\0D\0e\0p\0e\0n\0d\0e\0n\0c\0y\0\0\0"; 	
+const XMLCh* KDependencyList = (const XMLCh*)             "D\0e\0p\0e\0n\0d\0e\0n\0c\0y\0L\0i\0s\0t\0\0\0";
+const XMLCh* KRomApplication = (const XMLCh*)             "R\0o\0m\0A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0\0\0";
+const XMLCh* KApplicationRegistrationInfo = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0R\0e\0g\0i\0s\0t\0r\0a\0t\0i\0o\0n\0I\0n\0f\0o\0\0\0";
+const XMLCh* KOpaqueData = (const XMLCh*) 				  "O\0p\0a\0q\0u\0e\0D\0a\0t\0a\0\0\0";
+const XMLCh* KData = (const XMLCh*)						  "D\0a\0t\0a\0\0\0";
+const XMLCh* KOpaqueLocale = (const XMLCh*)				  "O\0p\0a\0q\0u\0e\0L\0o\0c\0a\0l\0e\0\0\0";
+const XMLCh* KIsBinary = (const XMLCh*)				  	  "I\0s\0B\0i\0n\0a\0r\0y\0\0\0";
+const XMLCh* KFileOwnershipinfo = (const XMLCh*)		  "F\0i\0l\0e\0O\0w\0n\0e\0r\0s\0h\0i\0p\0i\0n\0f\0o\0\0\0";
+const XMLCh* KFileName = (const XMLCh*) 				  "F\0i\0l\0e\0N\0a\0m\0e\0\0\0";
+const XMLCh* KApplicationLocalizableInfo = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0I\0n\0f\0o\0\0\0";
+const XMLCh* KLocalizableAttribute = (const XMLCh*)       "L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0A\0t\0t\0r\0i\0b\0u\0t\0e\0\0\0";
+const XMLCh* KLocalizableAttribute_Value = (const XMLCh*) "L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0A\0t\0t\0r\0i\0b\0u\0t\0e\0_\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KLocalizableAttribute_IntValue = (const XMLCh*) "L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0A\0t\0t\0r\0i\0b\0u\0t\0e\0_\0I\0n\0t\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KLocalizableAttribute_StrValue = (const XMLCh*) "L\0o\0c\0a\0l\0i\0z\0a\0b\0l\0e\0A\0t\0t\0r\0i\0b\0u\0t\0e\0_\0S\0t\0r\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KViewData = (const XMLCh*) "V\0i\0e\0w\0D\0a\0t\0a\0\0\0";
+const XMLCh* KViewDataAttribute = (const XMLCh*) "V\0i\0e\0w\0D\0a\0t\0a\0A\0t\0t\0r\0i\0b\0u\0t\0e\0\0\0";
+const XMLCh* KApplicationDataType = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0D\0a\0t\0a\0T\0y\0p\0e\0\0\0";
+const XMLCh* KPriority = (const XMLCh*) "P\0r\0i\0o\0r\0i\0t\0y\0\0\0";
+const XMLCh* KType = (const XMLCh*) "T\0y\0p\0e\0\0\0";
+const XMLCh* KViewData_Value = (const XMLCh*) "V\0i\0e\0w\0D\0a\0t\0a\0_\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KViewData_IntValue = (const XMLCh*) "V\0i\0e\0w\0D\0a\0t\0a\0_\0I\0n\0t\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KViewData_StrValue = (const XMLCh*) "V\0i\0e\0w\0D\0a\0t\0a\0_\0S\0t\0r\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KApplicationServiceInfo = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0S\0e\0r\0v\0i\0c\0e\0I\0n\0f\0o\0\0\0";
+const XMLCh* KUid = (const XMLCh*) "U\0i\0d\0\0\0";
+const XMLCh* KServiceOpaqueData = (const XMLCh*) "S\0e\0r\0v\0i\0c\0e\0O\0p\0a\0q\0u\0e\0D\0a\0t\0a\0\0\0";
+const XMLCh* KServiceData = (const XMLCh*) "S\0e\0r\0v\0i\0c\0e\0D\0a\0t\0a\0\0\0";
+const XMLCh* KServiceOpaqueLocale = (const XMLCh*) "S\0e\0r\0v\0i\0c\0e\0O\0p\0a\0q\0u\0e\0L\0o\0c\0a\0l\0e\0\0\0";
+const XMLCh* KApplicationProperty = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0P\0r\0o\0p\0e\0r\0t\0y\0\0\0";
+const XMLCh* KLocale = (const XMLCh*) "L\0o\0c\0a\0l\0e\0\0\0";
+const XMLCh* KServiceUid = (const XMLCh*) "S\0e\0r\0v\0i\0c\0e\0U\0i\0d\0\0\0";
+const XMLCh* KIntValue = (const XMLCh*) "I\0n\0t\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KStrValue = (const XMLCh*) "S\0t\0r\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KIsStr8Bit = (const XMLCh*) "I\0s\0S\0t\0r\08\0B\0i\0t\0\0\0";
+const XMLCh* KApplicationAttribute = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0A\0t\0t\0r\0i\0b\0u\0t\0e\0\0\0";
+const XMLCh* KApplicationAttribute_Value = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0A\0t\0t\0r\0i\0b\0u\0t\0e\0_\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KApplicationAttribute_IntValue = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0A\0t\0t\0r\0i\0b\0u\0t\0e\0_\0I\0n\0t\0V\0a\0l\0u\0e\0\0\0";
+const XMLCh* KApplicationAttribute_StrValue = (const XMLCh*) "A\0p\0p\0l\0i\0c\0a\0t\0i\0o\0n\0A\0t\0t\0r\0i\0b\0u\0t\0e\0_\0S\0t\0r\0V\0a\0l\0u\0e\0\0\0";
+
+
+
+
+//-----------------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------------------------------------------------------
+//											UTILITY FUNCTIONS
+//------------------------------------------------------------------------------------------------------------------------------
+
+XercesString ConvertToXercesString(const char* aString, int aLength)
+	{
+	XMLCh* buffer = new UTF16[aLength + 1];
+	XMLCh* temp = buffer; // save as buffer gets modified..
+	ConvertUTF8toUTF16(&aString, aString + aLength, &temp, buffer + aLength, lenientConversion);
+	
+	// Appending NUL to the converted buffer.
+	*temp = 0;
+
+	XercesString result;
+
+	result.append(buffer);
+	delete[] buffer;
+
+	return result;
+	}
+
+XercesString IntegerToXercesString(int aValue)
+	{
+	std::stringstream str;
+	str << aValue;
+
+	return ConvertToXercesString(str.str().c_str(), str.str().length());
+	}
+
+
+XercesString Int64ToXercesString(TInt64 aInt)
+	{
+	char str[50];
+	
+	sprintf(str, "%I64u", aInt);
+
+	return ConvertToXercesString(str, strlen(str));
+	}
+	
+
+//------------------------------------------------------------------------------------------------------------------------------
 
 
 CXmlGenerator::CXmlGenerator()
@@ -86,9 +215,14 @@
 		std::auto_ptr < SchemaDomErrorHandler > errHandler(new SchemaDomErrorHandler());
 		domWriter->setErrorHandler(errHandler.get());
 
+#ifdef _WIN32
+		// XMLString::trascode() function should be used for conversion.
 		std::auto_ptr < XMLFormatTarget > outputFile( new LocalFileFormatTarget( aXmlFileName.c_str() ) );	
-		
-		const char* epocRoot = getenv("EPOCROOT");
+#else
+        std::string fileName = wstring2string(aXmlFileName);
+		std::auto_ptr < XMLFormatTarget > outputFile( new LocalFileFormatTarget( fileName.c_str() ) );
+#endif // _WIN32		
+		const char* epocRoot = getenv("EPOCROOT");		
 		if(NULL == epocRoot)
 			{
 			throw std::runtime_error("EPOCROOT environment variable not specified.");
@@ -96,31 +230,33 @@
 		
 		std::string epocRootStr(epocRoot); 
 
-		std::string dtdFilePath = epocRootStr + "epoc32\\tools\\preprovision.dtd";
+		#ifdef __LINUX__ 
+		std::string dtdFilePath = epocRootStr + "epoc32/tools/preprovision.dtd";
+		#else 	  	  	 
+		std::string dtdFilePath = epocRootStr + "epoc32\\tools\\preprovision.dtd"; 	
+		#endif
 		
 		fn_auto_ptr<releaseXmlChPtr, XMLCh> dtdPath( &XMLString::release, XMLString::transcode(dtdFilePath.c_str()) );
-		DOMDocumentType* documentType = domImpl->createDocumentType(L"PreProvisionInformation",NULL, dtdPath.get());
+		DOMDocumentType* documentType = domImpl->createDocumentType(KPreProvisionInformation,NULL, dtdPath.get());
 		
 		
-		mem_fn_auto_ptr< releaseDOMDoc, DOMDocument* > domDocument( &XERCES_CPP_NAMESPACE::DOMDocument::release, domImpl->createDocument(	0, PreProvisionInformation.c_str(), documentType) );
+		mem_fn_auto_ptr< releaseDOMDoc, DOMDocument* > domDocument( &XERCES_CPP_NAMESPACE::DOMDocument::release, domImpl->createDocument(	0, KPreProvisionInformation, documentType) );
 
 		DOMElement* rootElement = domDocument->getDocumentElement();
 		
 		// SoftwareTypeName
-		AddChildElement(rootElement, domDocument.get(), SoftwareTypeName.c_str(), aPreProvisionDetail.iSoftwareTypeName.c_str() );
+		AddChildElement(rootElement, domDocument.get(), KSoftwareTypeName, aPreProvisionDetail.SoftwareTypeName().c_str() );
 
 		std::vector<XmlDetails::TScrPreProvisionDetail::TComponent>::const_iterator compIter;
 		for(compIter = aPreProvisionDetail.iComponents.begin(); compIter != aPreProvisionDetail.iComponents.end() ; ++compIter)
 			{
-			DOMElement*  component = domDocument->createElement(L"Component");
+			DOMElement*  component = domDocument->createElement(KComponent);
 			rootElement->appendChild(component);
 
 			WriteComponent(component,domDocument.get(), *compIter, aRomApplication);
 			}
-		
 		// do the serialization through DOMWriter::writeNode();
-		domWriter->writeNode(outputFile.get(), *domDocument.get());
-		
+		domWriter->writeNode(outputFile.get(), *domDocument.get()); 	  			
 		}
         catch (const XMLException& toCatch) 
 			{
@@ -144,7 +280,7 @@
 
 	if (aDomWriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
 		 aDomWriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
-	
+
 	if (aDomWriter->canSetFeature(XMLUni::fgDOMWRTNormalizeCharacters, false))
 		aDomWriter->setFeature(XMLUni::fgDOMWRTNormalizeCharacters, false);
 
@@ -163,7 +299,7 @@
 	if (aDomWriter->canSetFeature(XMLUni::fgDOMXMLDeclaration, true))
 		 aDomWriter->setFeature(XMLUni::fgDOMXMLDeclaration, true);
 	
-	aDomWriter->setEncoding(L"UTF-16");
+	aDomWriter->setEncoding(KUTF16);
 	}
 
 void CXmlGenerator::WriteComponent( DOMElement* aRootElement, DOMDocument* aDocument, 
@@ -175,28 +311,29 @@
 	if (aRomApplication) 
 	{
 		int isRomApplication = 1;
-		std::wstring isRomApp = Utils::IntegerToWideString(isRomApplication);
-		AddChildElement(aRootElement, aDocument, L"RomApplication", isRomApp.c_str());
+		XercesString isRomApp = IntegerToXercesString(isRomApplication);
+		AddChildElement(aRootElement, aDocument, KRomApplication, isRomApp.c_str());
 	}
 	
-	std::wstring isRemovable = Utils::IntegerToWideString(aComponent.iComponentDetails.iIsRemovable);
-	AddChildElement(aRootElement, aDocument, L"Removable", isRemovable.c_str() );
+	XercesString isRemovable = IntegerToXercesString(aComponent.iComponentDetails.iIsRemovable);
+	AddChildElement(aRootElement, aDocument, KRemovable, isRemovable.c_str() );
+
 	
-	std::wstring size = Utils::Int64ToWideString(aComponent.iComponentDetails.iSize);
-	AddChildElement(aRootElement, aDocument, L"Size", size.c_str() );
+	XercesString size = Int64ToXercesString(aComponent.iComponentDetails.iSize);
+	AddChildElement(aRootElement, aDocument, KSize, size.c_str() );
 	
-	std::wstring scomoState = Utils::IntegerToWideString(aComponent.iComponentDetails.iScomoState);
-	AddChildElement(aRootElement, aDocument, L"ScomoState", scomoState.c_str() );
+	XercesString scomoState = IntegerToXercesString(aComponent.iComponentDetails.iScomoState);
+	AddChildElement(aRootElement, aDocument, KScomoState, scomoState.c_str() );
 
-	AddChildElement(aRootElement, aDocument, L"GlobalId", aComponent.iComponentDetails.iGlobalId.c_str() );
+	AddChildElement(aRootElement, aDocument, KGlobalId, aComponent.iComponentDetails.GlobalId().c_str() );
 
 	WriteComponentVersion(aRootElement, aDocument, aComponent.iComponentDetails.iVersion);
 	
-	std::wstring isOriginVerified = Utils::IntegerToWideString(aComponent.iComponentDetails.iOriginVerified);
-	AddChildElement(aRootElement, aDocument, L"OriginVerified", isOriginVerified.c_str() );
+	XercesString isOriginVerified = Int64ToXercesString(aComponent.iComponentDetails.iOriginVerified);
+	AddChildElement(aRootElement, aDocument, KOriginVerified, isOriginVerified.c_str() );
 
-	std::wstring isHidden = Utils::IntegerToWideString(aComponent.iComponentDetails.iIsHidden);
-	AddChildElement(aRootElement, aDocument, L"Hidden", isHidden.c_str() );
+	XercesString isHidden = IntegerToXercesString(aComponent.iComponentDetails.iIsHidden);
+	AddChildElement(aRootElement, aDocument, KHidden, isHidden.c_str() );
 
 	WriteComponentLocalizables(aRootElement, aDocument, aComponent.iComponentLocalizables);
 
@@ -217,11 +354,11 @@
 				XmlDetails::TScrPreProvisionDetail::TComponentDetails::TVersion aVersion
 				)
 	{
-	DOMElement*  version = aDocument->createElement(L"Version");
+	DOMElement*  version = aDocument->createElement(KVersion);
 	aRootElement->appendChild(version);
-	version->setAttribute( L"Major", aVersion.iMajor.c_str() );
-	version->setAttribute( L"Minor", aVersion.iMinor.c_str() );
-	version->setAttribute( L"Build", aVersion.iBuild.c_str() );
+	version->setAttribute( KMajor, aVersion.MajorVersion().c_str() );
+	version->setAttribute( KMinor, aVersion.MinorVersion().c_str() );
+	version->setAttribute( KBuild, aVersion.BuildVersion().c_str() );
 	}
 
 void CXmlGenerator::WriteComponentLocalizables
@@ -233,11 +370,13 @@
 	std::vector<ComponentLocalizable>::const_iterator compLocIter;
 	for( compLocIter = aComponentLocalizable.begin() ; compLocIter != aComponentLocalizable.end() ; ++compLocIter)
 		{
-		DOMElement* newRoot = AddTag(aRootElement, aDocument, L"ComponentLocalizable");
-		std::wstring locale = Utils::IntegerToWideString(compLocIter->iLocale);
-		AddChildElement(newRoot,aDocument, L"ComponentLocalizable_Locale", locale.c_str());
-		AddChildElement(newRoot,aDocument, L"ComponentLocalizable_Name", compLocIter->iName.c_str());
-		AddChildElement(newRoot,aDocument, L"ComponentLocalizable_Vendor", compLocIter->iVendor.c_str());
+		DOMElement* newRoot = AddTag(aRootElement, aDocument, KComponentLocalizable);
+		XercesString locale = IntegerToXercesString(compLocIter->iLocale);
+
+
+		AddChildElement(newRoot,aDocument, KComponentLocalizable_Locale, locale.c_str());
+		AddChildElement(newRoot,aDocument, KComponentLocalizable_Name, compLocIter->Name().c_str());
+		AddChildElement(newRoot,aDocument, KComponentLocalizable_Vendor, compLocIter->Vendor().c_str());
 		}
 	}
 
@@ -251,28 +390,28 @@
 	for( compPropIter = aComponentProperties.begin() ; compPropIter != aComponentProperties.end() ; ++compPropIter)
 		{
 		
-		DOMElement* compPropRoot = AddTag(aRootElement, aDocument, L"ComponentProperty");
+		DOMElement* compPropRoot = AddTag(aRootElement, aDocument, KComponentProperty);
 		
-		std::wstring locale = Utils::IntegerToWideString(compPropIter->iLocale);
-		AddChildElement(compPropRoot,aDocument, L"ComponentProperty_Locale", locale.c_str());
+		XercesString locale = IntegerToXercesString(compPropIter->iLocale);
+		AddChildElement(compPropRoot,aDocument, KComponentProperty_Locale, locale.c_str());
 		
-		DOMElement* compPropValueRoot = AddTag(compPropRoot, aDocument, L"ComponentProperty_Value");
+		DOMElement* compPropValueRoot = AddTag(compPropRoot, aDocument, KComponentProperty_Value);
 		
-		std::wstring isBinary = Utils::IntegerToWideString(compPropIter->iIsStr8Bit);
+		XercesString isBinary = IntegerToXercesString(compPropIter->iIsStr8Bit);
 
 		if(compPropIter->iIsIntValue)
 			{
-			AddChildElement(compPropValueRoot,aDocument, L"ComponentProperty_IntValue", compPropIter->iValue.c_str());
+			AddChildElement(compPropValueRoot,aDocument, KComponentProperty_IntValue, compPropIter->Value().c_str());
 			}
 		else
 			{
-			AddChildElement(compPropValueRoot,aDocument, L"ComponentProperty_StrValue", compPropIter->iValue.c_str());
+			AddChildElement(compPropValueRoot,aDocument, KComponentProperty_StrValue, compPropIter->Value().c_str());
 			}
 		
 		
-		AddChildElement(compPropRoot,aDocument, L"ComponentProperty_IsBinary", isBinary.c_str());
+		AddChildElement(compPropRoot,aDocument, KComponentProperty_IsBinary, isBinary.c_str());
 
-		compPropRoot->setAttribute(L"Name", compPropIter->iName.c_str());
+		compPropRoot->setAttribute(KName, compPropIter->Name().c_str());
 		
 		}
 	}
@@ -291,7 +430,7 @@
 	std::vector<AppRegistrationInfo>::const_iterator compFileIter;
 	for( compFileIter = aAppRegInfo.begin() ; compFileIter != aAppRegInfo.end() ; ++compFileIter)
 	{
-		DOMElement* compFileRoot = AddTag(aRootElement, aDocument, L"ApplicationRegistrationInfo");
+		DOMElement* compFileRoot = AddTag(aRootElement, aDocument, KApplicationRegistrationInfo);
 
 		WriteAppAttributes(compFileRoot, aDocument, compFileIter->iApplicationAttribute);
 
@@ -302,18 +441,35 @@
 		{
 			if(0 == fileAppOpaqueDataType->iServiceUid)
 			{
-				DOMElement* filePropValueRoot = AddTag(compFileRoot, aDocument, L"OpaqueData");
-				AddChildElement(filePropValueRoot,aDocument, L"Data", fileAppOpaqueDataType->iOpaqueData.c_str());
-				std::wstring iLocale = Utils::IntegerToWideString(fileAppOpaqueDataType->iLocale);
-				AddChildElement(filePropValueRoot,aDocument, L"OpaqueLocale", iLocale.c_str());
+				DOMElement* filePropValueRoot = AddTag(compFileRoot, aDocument, KOpaqueData);
+				
+				if(fileAppOpaqueDataType->iIsBinary)
+				{
+					std::string temp = wstring2string(fileAppOpaqueDataType->iOpaqueData);
+					std::string binStrData = Util::Base64Encode(temp);
+					std::wstring binData = string2wstring(binStrData);
+					AddChildElement(filePropValueRoot,aDocument, KData, binData.c_str());
+				}
+				else
+				{
+					AddChildElement(filePropValueRoot,aDocument, KData, fileAppOpaqueDataType->iOpaqueData.c_str());
+				}
+				
+				XercesString locale = IntegerToXercesString(fileAppOpaqueDataType->iLocale);
+				AddChildElement(filePropValueRoot,aDocument, KOpaqueLocale, locale.c_str());
+
+				XercesString iBinary = IntegerToXercesString(fileAppOpaqueDataType->iIsBinary);
+				AddChildElement(filePropValueRoot,aDocument, KIsBinary, iBinary.c_str());
+				
 			}
 		}
 
 		for(vector<std::wstring>::iterator mimeiter = compFileIter->iFileOwnershipInfo.begin() ; mimeiter != compFileIter->iFileOwnershipInfo.end() ; ++mimeiter )
 		{
-			DOMElement* filePropRoot = AddTag(compFileRoot, aDocument, L"FileOwnershipinfo");
+			DOMElement* filePropRoot = AddTag(compFileRoot, aDocument, KFileOwnershipinfo);
 
-			AddChildElement(filePropRoot,aDocument, L"FileName",  mimeiter->c_str());
+			XercesString temp = WStringToXercesString(*mimeiter);
+			AddChildElement(filePropRoot,aDocument, KFileName,  temp.c_str());
 		}
 
 		WriteAppServiceInfo(compFileRoot, aDocument, compFileIter->iApplicationServiceInfo, compFileIter->iOpaqueDataType);
@@ -334,7 +490,7 @@
 	std::vector<AppLocalizableInfo>::const_iterator filePropIter;
 	for( filePropIter = aAppLocalizableInfo.begin() ; filePropIter != aAppLocalizableInfo.end() ; ++filePropIter)
 	{
-		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationLocalizableInfo");
+		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KApplicationLocalizableInfo);
 
 		WriteAppLocalizableAttribute(filePropRoot, aDocument, filePropIter->iLocalizableAttribute);
 		WriteAppLocalizableViewData(filePropRoot, aDocument, filePropIter->iViewData);
@@ -354,18 +510,20 @@
 	std::vector<AppLocalizableAttribute>::const_iterator filePropIter;
 	for( filePropIter = aAppLocalizableAttribute.begin() ; filePropIter != aAppLocalizableAttribute.end() ; ++filePropIter)
 	{
-		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"LocalizableAttribute");
-		DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"LocalizableAttribute_Value");
+		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KLocalizableAttribute);
+		DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, KLocalizableAttribute_Value);
 
+		XercesString value = WStringToXercesString(filePropIter->iValue);
 		if(filePropIter->iIsIntValue)
 		{
-			AddChildElement(filePropValueRoot, aDocument, L"LocalizableAttribute_IntValue", filePropIter->iValue.c_str());
+			AddChildElement(filePropValueRoot, aDocument, KLocalizableAttribute_IntValue, value.c_str());
 		}
 		else
 		{
-			AddChildElement(filePropValueRoot, aDocument, L"LocalizableAttribute_StrValue", filePropIter->iValue.c_str());
+			AddChildElement(filePropValueRoot, aDocument, KLocalizableAttribute_StrValue, value.c_str());
 		}
-		filePropRoot->setAttribute(L"Name", filePropIter->iName.c_str());
+		XercesString name = WStringToXercesString(filePropIter->iName);
+		filePropRoot->setAttribute(KName, name.c_str());
 	}
 }
 
@@ -382,7 +540,7 @@
 	 std::vector<AppViewData>::const_iterator filePropIter;
 	 for( filePropIter = aAppViewData.begin() ; filePropIter != aAppViewData.end() ; ++filePropIter)
 	 {
-		 DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ViewData");
+		 DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KViewData);
 		 WriteAppLocalizableViewDataAttributes(filePropRoot, aDocument, filePropIter->iViewDataAttributes);
 	 }
  }
@@ -396,18 +554,23 @@
 	 std::vector<AppViewDataAttributes>::const_iterator filePropIter;
 	 for( filePropIter = aAppViewDataAttributes.begin() ; filePropIter != aAppViewDataAttributes.end() ; ++filePropIter)
 	 {
-		 DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ViewDataAttribute");
-		 DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"ViewData_Value");
+		 DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KViewDataAttribute);
+		 DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, KViewData_Value);
  
+		 XercesString value = WStringToXercesString(filePropIter->iValue);
 		 if(filePropIter->iIsIntValue)
 		 {
-			 AddChildElement(filePropValueRoot, aDocument, L"ViewData_IntValue", filePropIter->iValue.c_str());
+			 AddChildElement(filePropValueRoot, aDocument, KViewData_IntValue, value.c_str());
+
 		 }
 		 else
 		 {
-			 AddChildElement(filePropValueRoot, aDocument, L"ViewData_StrValue", filePropIter->iValue.c_str());
+			 AddChildElement(filePropValueRoot, aDocument, KViewData_StrValue, value.c_str());
+
 		 }
-		 filePropRoot->setAttribute(L"Name", filePropIter->iName.c_str());
+
+		 XercesString name = WStringToXercesString(filePropIter->iName);
+		 filePropRoot->setAttribute(KName, name.c_str());
 	 }
  }
 
@@ -426,10 +589,11 @@
 	std::vector<AppOpaqueDataType>::const_iterator fileAppPropIter;
 	for( filePropIter = aAppServiceInfo.begin() ; filePropIter != aAppServiceInfo.end() ; ++filePropIter)
 	{
-		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationServiceInfo");
+		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KApplicationServiceInfo);
 	
-		std::wstring iUid = Utils::IntegerToWideString(filePropIter->iUid);
-		AddChildElement(filePropRoot,aDocument, L"Uid", iUid.c_str());
+		XercesString uid = IntegerToXercesString(filePropIter->iUid);
+		AddChildElement(filePropRoot,aDocument, KUid, uid.c_str());
+
 
 		for( fileAppPropIter = aAppOpaqueData.begin() ; fileAppPropIter != aAppOpaqueData.end() ; ++fileAppPropIter)
 		{
@@ -437,10 +601,13 @@
 			{
 				if(!fileAppPropIter->iOpaqueData.empty())
 				{
-					DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"ServiceOpaqueData");
-					AddChildElement(filePropValueRoot,aDocument, L"ServiceData", fileAppPropIter->iOpaqueData.c_str());
-					std::wstring iLocale = Utils::IntegerToWideString(fileAppPropIter->iLocale);
-					AddChildElement(filePropValueRoot,aDocument, L"ServiceOpaqueLocale", iLocale.c_str());
+					DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, KServiceOpaqueData);
+
+					XercesString opaqueData = WStringToXercesString(fileAppPropIter->iOpaqueData);
+					AddChildElement(filePropValueRoot,aDocument, KServiceData, opaqueData.c_str());
+
+					XercesString locale = IntegerToXercesString(fileAppPropIter->iLocale);
+					AddChildElement(filePropValueRoot,aDocument, KServiceOpaqueLocale, locale.c_str());
 				}
 			}
 		}
@@ -462,11 +629,13 @@
 	std::vector<AppDataType>::const_iterator filePropIter;
 	for( filePropIter = aAppDataType.begin() ; filePropIter != aAppDataType.end() ; ++filePropIter)
 	{
-		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationDataType");
+		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KApplicationDataType);
 
-		std::wstring iPriority = Utils::IntegerToWideString(filePropIter->iPriority);
-		AddChildElement(filePropRoot,aDocument, L"Priority", iPriority.c_str());
-		AddChildElement(filePropRoot, aDocument, L"Type", filePropIter->iType.c_str());
+		XercesString priority = IntegerToXercesString(filePropIter->iPriority);
+		AddChildElement(filePropRoot,aDocument, KPriority, priority.c_str());
+
+		XercesString type = WStringToXercesString(filePropIter->iType);
+		AddChildElement(filePropRoot, aDocument, KType, type.c_str());
 	}
 }
 
@@ -483,18 +652,22 @@
 	std::vector<ApplicationAttribute>::const_iterator filePropIter;
 	for( filePropIter = aAppAttributes.begin() ; filePropIter != aAppAttributes.end() ; ++filePropIter)
 	{
-		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationAttribute");
-		DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"ApplicationAttribute_Value");
+		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KApplicationAttribute);
 
+		DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, KApplicationAttribute_Value);
+
+		XercesString value = WStringToXercesString(filePropIter->iValue);
 		if(filePropIter->iIsIntValue)
 		{
-			AddChildElement(filePropValueRoot, aDocument, L"ApplicationAttribute_IntValue", filePropIter->iValue.c_str());
+			AddChildElement(filePropValueRoot, aDocument, KApplicationAttribute_IntValue, value.c_str());
 		}
 		else
 		{
-			AddChildElement(filePropValueRoot, aDocument, L"ApplicationAttribute_StrValue", filePropIter->iValue.c_str());
+			AddChildElement(filePropValueRoot, aDocument, KApplicationAttribute_StrValue, value.c_str());
 		}
-		filePropRoot->setAttribute(L"Name", filePropIter->iName.c_str());
+
+		XercesString name = WStringToXercesString(filePropIter->iName);
+		filePropRoot->setAttribute(KName, name.c_str());
 	}
 }
 
@@ -510,25 +683,25 @@
 	std::vector<AppProperty>::const_iterator filePropIter;
 	for( filePropIter = aAppProperty.begin() ; filePropIter != aAppProperty.end() ; ++filePropIter)
 	{
-		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"ApplicationProperty");
-
+		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KApplicationProperty);
 
-		std::wstring iLocale = Utils::IntegerToWideString(filePropIter->iLocale);
-		AddChildElement(filePropRoot,aDocument, L"Locale", iLocale.c_str());
+		XercesString locale = IntegerToXercesString(filePropIter->iLocale);
+		AddChildElement(filePropRoot,aDocument, KLocale, locale.c_str());
 
-		AddChildElement(filePropRoot,aDocument, L"Name", filePropIter->iName.c_str());
+		XercesString name = WStringToXercesString(filePropIter->iName);
+		AddChildElement(filePropRoot,aDocument, KName, name.c_str());
 
-		std::wstring iServiceUid = Utils::IntegerToWideString(filePropIter->iServiceUid);
-		AddChildElement(filePropRoot,aDocument, L"ServiceUid", iServiceUid.c_str());
+		XercesString serviceUid = IntegerToXercesString(filePropIter->iServiceUid);
+		AddChildElement(filePropRoot,aDocument, KServiceUid, serviceUid.c_str());
 
-		std::wstring iIntValue = Utils::IntegerToWideString(filePropIter->iIntValue);
-		AddChildElement(filePropRoot,aDocument, L"IntValue", iIntValue.c_str());
+		XercesString intValue = IntegerToXercesString(filePropIter->iIntValue);
+		AddChildElement(filePropRoot,aDocument, KIntValue, intValue.c_str());
 
-		AddChildElement(filePropRoot, aDocument, L"StrValue", filePropIter->iStrValue.c_str());
+		XercesString strValue = WStringToXercesString(filePropIter->iStrValue);
+		AddChildElement(filePropRoot, aDocument, KStrValue, strValue.c_str());
 
-		std::wstring iIsStr8Bit = Utils::IntegerToWideString(filePropIter->iIsStr8Bit);
-		AddChildElement(filePropRoot,aDocument, L"IsStr8Bit", iIsStr8Bit.c_str());
-
+		XercesString isStr8Bit = IntegerToXercesString(filePropIter->iIsStr8Bit);
+		AddChildElement(filePropRoot,aDocument, KIsStr8Bit, isStr8Bit.c_str());
 	}
 }
 
@@ -541,11 +714,11 @@
 	std::vector<ComponentFile>::const_iterator compFileIter;
 	for( compFileIter = aComponentFiles.begin() ; compFileIter != aComponentFiles.end() ; ++compFileIter)
 		{
-		DOMElement* compFileRoot = AddTag(aRootElement, aDocument, L"ComponentFile");
+		DOMElement* compFileRoot = AddTag(aRootElement, aDocument, KComponentFile);
 
 		WriteFileProperties(compFileRoot, aDocument, compFileIter->iFileProperties);
 		
-		compFileRoot->setAttribute(L"Location", compFileIter->iLocation.c_str());
+		compFileRoot->setAttribute(KLocation, compFileIter->Location().c_str());
 		}
 	}
 
@@ -558,18 +731,18 @@
 	std::vector<FileProperty>::const_iterator filePropIter;
 	for( filePropIter = aFileProperties.begin() ; filePropIter != aFileProperties.end() ; ++filePropIter)
 		{
-		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, L"FileProperty");
-		DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, L"FileProperty_Value");
+		DOMElement* filePropRoot = AddTag(aRootElement, aDocument, KFileProperty);
+		DOMElement* filePropValueRoot = AddTag(filePropRoot, aDocument, KFileProperty_Value);
 
 		if(filePropIter->iIsIntValue)
 			{
-			AddChildElement(filePropValueRoot, aDocument, L"FileProperty_IntValue", filePropIter->iValue.c_str());
+			AddChildElement(filePropValueRoot, aDocument, KFileProperty_IntValue, filePropIter->Value().c_str());
 			}
 		else
 			{
-			AddChildElement(filePropValueRoot, aDocument, L"FileProperty_StrValue", filePropIter->iValue.c_str());
+			AddChildElement(filePropValueRoot, aDocument, KFileProperty_StrValue, filePropIter->Value().c_str());
 			}
-		filePropRoot->setAttribute(L"Name", filePropIter->iName.c_str());
+		filePropRoot->setAttribute(KName, filePropIter->Name().c_str());
 		}
 	}
 
@@ -587,20 +760,20 @@
 	std::vector<ComponentDependencyDetail> componentDependencyList = aComponentDependency.iComponentDependencyList;
 	std::vector<ComponentDependencyDetail>::const_iterator compDepIter;
 
-	DOMElement* compDepRoot = AddTag(aRootElement, aDocument, L"ComponentDependency");
+	DOMElement* compDepRoot = AddTag(aRootElement, aDocument, KComponentDependency);
 
 	for( compDepIter = componentDependencyList.begin() ; compDepIter != componentDependencyList.end() ; ++compDepIter)
 		{
-		DOMElement* compDepListRoot = AddTag( compDepRoot, aDocument, L"DependencyList" );
-		AddChildElement( compDepListRoot, aDocument, L"SupplierId", compDepIter->iSupplierId.c_str() );
-		AddChildElement( compDepListRoot, aDocument, L"FromVersion", compDepIter->iFromVersion.c_str() );
-		AddChildElement( compDepListRoot, aDocument, L"ToVersion", compDepIter->iToVersion.c_str() );
+		DOMElement* compDepListRoot = AddTag( compDepRoot, aDocument, KDependencyList );
+		AddChildElement( compDepListRoot, aDocument, KSupplierId, compDepIter->SupplierId().c_str() );
+		AddChildElement( compDepListRoot, aDocument, KFromVersion, compDepIter->FromVersion().c_str() );
+		AddChildElement( compDepListRoot, aDocument, KToVersion, compDepIter->ToVersion().c_str() );
 		}
-	compDepRoot->setAttribute(L"DependentId", aComponentDependency.iDependentId.c_str());
+	compDepRoot->setAttribute(KDependentId, aComponentDependency.DependentId().c_str());
 	}
 
 
-void CXmlGenerator::AddChildElement( DOMElement* aRootElement, DOMDocument* aDocument, const wchar_t* aElementName, const wchar_t* aTextValue )
+void CXmlGenerator::AddChildElement( DOMElement* aRootElement, DOMDocument* aDocument, const XMLCh* aElementName, const XMLCh* aTextValue )
 	{
 	DOMElement*  element = aDocument->createElement(aElementName);
 	aRootElement->appendChild(element);
@@ -609,7 +782,7 @@
 	element->appendChild(textValue);
 	}
 
-DOMElement* CXmlGenerator::AddTag( DOMElement* aRootElement, DOMDocument* aDocument, const wchar_t* aTagName)
+DOMElement* CXmlGenerator::AddTag( DOMElement* aRootElement, DOMDocument* aDocument, const XMLCh* aTagName)
 	{
 	DOMElement*  tagName = aDocument->createElement(aTagName);
 	aRootElement->appendChild(tagName);
@@ -623,6 +796,8 @@
  */
 bool SchemaDomErrorHandler::handleError(const DOMError& domError)
 	{
-	const XMLCh* message = domError.getMessage();
+	const XMLCh* message = domError.getMessage();	
 	return false;
 	}
+
+