PFW: Add two commands to print xml settings and structure

BZ: 44910

Creates two commands that can be called through the command
line of the parameter-framework. First command getDomainXML
returns a string containing the xml structure of the
domains, configurations and settings. Second command
getSystemClassXML returns a string containing the xml
structure of all the instantiated parameter with their
attributes.

Change-Id: I9a35333802049a2177b8fc416754fdb67e6efff0
Signed-off-by: Georges-Henri Baron <georges-henrix.baron@intel.com>
Reviewed-on: http://android.intel.com:8080/55155
Reviewed-by: Rocard, KevinX <kevinx.rocard@intel.com>
Reviewed-by: Centelles, Sylvain <sylvain.centelles@intel.com>
Tested-by: Mendi, EduardoX <eduardox.mendi@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/xmlserializer/Android.mk b/xmlserializer/Android.mk
index 7aa4e74..b1a41f6 100644
--- a/xmlserializer/Android.mk
+++ b/xmlserializer/Android.mk
@@ -5,11 +5,15 @@
 LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
 
 LOCAL_SRC_FILES:= \
-        XmlParser.cpp \
         XmlElement.cpp \
-        XmlComposer.cpp \
         XmlSerializingContext.cpp \
-        XmlSerializer.cpp
+        XmlDocSource.cpp \
+        XmlDocSink.cpp \
+        XmlMemoryDocSink.cpp \
+        XmlMemoryDocSource.cpp \
+        XmlStringDocSink.cpp \
+        XmlFileDocSink.cpp \
+        XmlFileDocSource.cpp
 
 LOCAL_MODULE:= libxmlserializer
 
diff --git a/xmlserializer/XmlComposer.cpp b/xmlserializer/XmlComposer.cpp
deleted file mode 100644
index d00a21e..0000000
--- a/xmlserializer/XmlComposer.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/* 
- * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
- * Corporation All Rights Reserved.
- * 
- * The source code contained or described herein and all documents related to
- * the source code ("Material") are owned by Intel Corporation or its suppliers
- * or licensors. Title to the Material remains with Intel Corporation or its
- * suppliers and licensors. The Material contains trade secrets and proprietary
- * and confidential information of Intel or its suppliers and licensors. The
- * Material is protected by worldwide copyright and trade secret laws and
- * treaty provisions. No part of the Material may be used, copied, reproduced,
- * modified, published, uploaded, posted, transmitted, distributed, or
- * disclosed in any way without Intel’s prior express written permission.
- * 
- * No license under any patent, copyright, trade secret or other intellectual
- * property right is granted to or conferred upon you by disclosure or delivery
- * of the Materials, either expressly, by implication, inducement, estoppel or
- * otherwise. Any license under such intellectual property rights must be
- * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
- */
-#include "XmlComposer.h"
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <sys/time.h>
-
-#define base CXmlSerializer
-
-#ifndef LIBXML_TREE_ENABLED
-#warning "LIBXML_TREE_ENABLED undefined. XML file exporting feature won't be supported!"
-#endif
-
-CXmlComposer::CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext) :
-    base(strXmlInstanceFile, strXmlSchemaFile, strRootElementType, serializingContext)
-{
-}
-
-CXmlComposer::~CXmlComposer()
-{
-}
-
-// open / close
-bool CXmlComposer::open()
-{
-#ifdef LIBXML_TREE_ENABLED
-    // Create document from scratch
-    _pDoc = xmlNewDoc(BAD_CAST "1.0");
-
-    // Create root node
-    _pRootNode = xmlNewNode(NULL, BAD_CAST _strRootElementType.c_str());
-
-    // Assign it to document
-    xmlDocSetRootElement(_pDoc, _pRootNode);
-#else
-    _serializingContext.setError("XML file exporting feature unsupported on this image. This easiest way to activate it is to do a global recompilation with LIBXML_TREE_ENABLED compiler switch set");
-#endif
-    return base::open();
-}
-
-bool CXmlComposer::close()
-{
-    // Write file (formatted)
-    if (xmlSaveFormatFileEnc(_strXmlInstanceFile.c_str(), _pDoc, "UTF-8", 1) == -1) {
-
-        _serializingContext.setError("Could not write file " + _strXmlInstanceFile);
-
-        return false;
-    }
-
-    return base::close();
-}
-
-// Composing contents
-void CXmlComposer::compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion)
-{
-    // Compose document
-    CXmlElement docElement(_pRootNode);
-
-    // Schema namespace
-    docElement.setAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
-
-    // Schema location
-    docElement.setAttributeString("xsi:noNamespaceSchemaLocation", _strXmlSchemaFile);
-
-    // Comment for date/time
-    docElement.setComment(string(" Exported on ") + getTimeAsString() + " from " + strProduct + " version " + strVersion + " ");
-
-    pXmlSource->toXml(docElement, _serializingContext);
-}
-
-string CXmlComposer::getTimeAsString()
-{
-    char acBuf[200];
-    time_t t;
-    struct tm *tmp;
-    t = time(NULL);
-    tmp = localtime(&t);
-
-    strftime(acBuf, sizeof(acBuf), "%F, %T", tmp);
-
-    return acBuf;
-}
diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlDocSink.cpp
similarity index 62%
copy from xmlserializer/XmlComposer.h
copy to xmlserializer/XmlDocSink.cpp
index 9e50de8..dedfcf8 100644
--- a/xmlserializer/XmlComposer.h
+++ b/xmlserializer/XmlDocSink.cpp
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,38 +12,28 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
-#pragma once
 
-#include "XmlSerializer.h"
-#include "XmlSource.h"
+#include "XmlDocSink.h"
 
-struct _xmlDoc;
-struct _xmlNode;
-
-class CXmlComposer : public CXmlSerializer
+CXmlDocSink::CXmlDocSink()
 {
-public:
-    CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlComposer();
+}
 
-    // open / close
-    virtual bool open();
-    virtual bool close();
+// Source Processing
+bool CXmlDocSink::process(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext)
+{
+    if (!xmlDocSource.populate(serializingContext)) {
+        return false;
+    }
 
-    // Composing contents
-    void compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion);
-
-private:
-    static string getTimeAsString();
-};
-
+    return doProcess(xmlDocSource, serializingContext);
+}
diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlDocSink.h
similarity index 64%
copy from xmlserializer/XmlComposer.h
copy to xmlserializer/XmlDocSink.h
index 9e50de8..e1b2fc3 100644
--- a/xmlserializer/XmlComposer.h
+++ b/xmlserializer/XmlDocSink.h
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,38 +12,30 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
+
 #pragma once
 
-#include "XmlSerializer.h"
-#include "XmlSource.h"
+#include "XmlDocSource.h"
+#include "XmlSerializingContext.h"
 
-struct _xmlDoc;
-struct _xmlNode;
-
-class CXmlComposer : public CXmlSerializer
+class CXmlDocSink
 {
 public:
-    CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlComposer();
+    CXmlDocSink();
 
-    // open / close
-    virtual bool open();
-    virtual bool close();
-
-    // Composing contents
-    void compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion);
+    // Source processing
+    bool process(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext);
 
 private:
-    static string getTimeAsString();
+    // Handle for subclasses to process the source
+    virtual bool doProcess(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext) = 0;
 };
-
diff --git a/xmlserializer/XmlSerializer.cpp b/xmlserializer/XmlDocSource.cpp
similarity index 61%
rename from xmlserializer/XmlSerializer.cpp
rename to xmlserializer/XmlDocSource.cpp
index d3e18f9..e876f16 100644
--- a/xmlserializer/XmlSerializer.cpp
+++ b/xmlserializer/XmlDocSource.cpp
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,25 +12,24 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
-#include "XmlSerializer.h"
+#include "XmlDocSource.h"
 #include <libxml/tree.h>
 #include <stdlib.h>
 
 // Schedule for libxml2 library
-bool CXmlSerializer::_bLibXml2CleanupScheduled;
+bool CXmlDocSource::_bLibXml2CleanupScheduled;
 
-CXmlSerializer::CXmlSerializer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext) :
-    _strXmlInstanceFile(strXmlInstanceFile), _strXmlSchemaFile(strXmlSchemaFile), _strRootElementType(strRootElementType), _serializingContext(serializingContext), _pDoc(NULL), _pRootNode(NULL)
+CXmlDocSource::CXmlDocSource(_xmlDoc *pDoc, _xmlNode *pRootNode):
+      _pDoc(pDoc), _pRootNode(pRootNode)
 {
     if (!_bLibXml2CleanupScheduled) {
 
@@ -39,45 +38,42 @@
 
         _bLibXml2CleanupScheduled = true;
     }
+
+    if (!_pRootNode) {
+
+        _pRootNode = xmlDocGetRootElement(_pDoc);
+    }
 }
 
-CXmlSerializer::~CXmlSerializer()
+CXmlDocSource::~CXmlDocSource()
 {
-    // Free XML doc
-    xmlFreeDoc(_pDoc);
-}
-
-bool CXmlSerializer::close()
-{
-    // Free XML doc
-    xmlFreeDoc(_pDoc);
-
-    _pDoc = NULL;
-
-    return true;
-}
-
-bool CXmlSerializer::open()
-{
-    return _pDoc != NULL;
+    if (_pDoc) {
+        // Free XML doc
+        xmlFreeDoc(_pDoc);
+        _pDoc = NULL;
+    }
 }
 
 // Root element
-void CXmlSerializer::getRootElement(CXmlElement& xmlRootElement) const
+void CXmlDocSource::getRootElement(CXmlElement& xmlRootElement) const
 {
     xmlRootElement.setXmlElement(_pRootNode);
 }
 
-string CXmlSerializer::getRootElementName() const
+string CXmlDocSource::getRootElementName() const
 {
     return (const char*)_pRootNode->name;
 }
 
-string CXmlSerializer::getRootElementAttributeString(const string& strAttributeName) const
+string CXmlDocSource::getRootElementAttributeString(const string& strAttributeName) const
 {
     CXmlElement topMostElement(_pRootNode);
 
     return topMostElement.getAttributeString(strAttributeName);
 }
 
+_xmlDoc* CXmlDocSource::getDoc() const
+{
+    return _pDoc;
+}
 
diff --git a/xmlserializer/XmlSerializer.h b/xmlserializer/XmlDocSource.h
similarity index 71%
rename from xmlserializer/XmlSerializer.h
rename to xmlserializer/XmlDocSource.h
index 91a95b0..a59919e 100644
--- a/xmlserializer/XmlSerializer.h
+++ b/xmlserializer/XmlDocSource.h
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,16 +12,16 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
+
 #pragma once
 
 #include "XmlElement.h"
@@ -30,34 +30,27 @@
 struct _xmlDoc;
 struct _xmlNode;
 
-class CXmlSerializer
+class CXmlDocSource
 {
 public:
-    CXmlSerializer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlSerializer();
+    CXmlDocSource(_xmlDoc* pDoc, _xmlNode* pRootNode = NULL);
+    virtual ~CXmlDocSource();
 
-    // Open/Close
-    virtual bool open();
-    virtual bool close();
+    // Method Called by the CXmlDocSink::process method
+    virtual bool populate(CXmlSerializingContext& serializingContext) = 0;
 
     // Root element
     void getRootElement(CXmlElement& xmlRootElement) const;
     string getRootElementName() const;
     string getRootElementAttributeString(const string& strAttributeName) const;
+
+    // Method that returns the xmlDoc contained in the Source. (Can be used in a Doc Sink)
+    _xmlDoc* getDoc() const;
+
+
 protected:
-    // Instance file
-    string _strXmlInstanceFile;
 
-    // Schema file
-    string _strXmlSchemaFile;
-
-    // Root element type
-    string _strRootElementType;
-
-    // Serializing context
-    CXmlSerializingContext& _serializingContext;
-
-    // XML document
+    // Doc
     _xmlDoc* _pDoc;
 
     // Root node
diff --git a/xmlserializer/XmlElement.cpp b/xmlserializer/XmlElement.cpp
index ffd5787..9f3f84a 100644
--- a/xmlserializer/XmlElement.cpp
+++ b/xmlserializer/XmlElement.cpp
@@ -25,6 +25,7 @@
 #include "XmlElement.h"
 #include <libxml/tree.h>
 #include <stdlib.h>
+#include <sstream>
 
 CXmlElement::CXmlElement(_xmlNode* pXmlElement) : _pXmlElement(pXmlElement)
 {
@@ -199,6 +200,13 @@
     xmlNewProp(_pXmlElement, BAD_CAST strAttributeName.c_str(), BAD_CAST strValue.c_str());
 }
 
+void CXmlElement::setAttributeInteger(const string& strAttributeName, uint32_t uiValue)
+{
+   ostringstream strStream;
+   strStream << uiValue;
+   setAttributeString(strAttributeName, strStream.str());
+}
+
 void CXmlElement::setNameAttribute(const string& strValue)
 {
     setAttributeString("Name", strValue);
diff --git a/xmlserializer/XmlElement.h b/xmlserializer/XmlElement.h
index 62de769..a1bf42c 100644
--- a/xmlserializer/XmlElement.h
+++ b/xmlserializer/XmlElement.h
@@ -67,6 +67,7 @@
     void setNameAttribute(const string& strValue);
     void setTextContent(const string& strContent);
     void setComment(const string& strComment);
+    void setAttributeInteger(const string& strAttributeName, uint32_t uiValue);
 
     // Child creation
     void createChild(CXmlElement& childElement, const string& strType);
diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlFileDocSink.cpp
similarity index 62%
copy from xmlserializer/XmlComposer.h
copy to xmlserializer/XmlFileDocSink.cpp
index 9e50de8..4a2b13f 100644
--- a/xmlserializer/XmlComposer.h
+++ b/xmlserializer/XmlFileDocSink.cpp
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,38 +12,35 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
-#pragma once
 
-#include "XmlSerializer.h"
-#include "XmlSource.h"
+#include "XmlFileDocSink.h"
+#include <libxml/parser.h>
 
-struct _xmlDoc;
-struct _xmlNode;
+#define base CXmlDocSink
 
-class CXmlComposer : public CXmlSerializer
+CXmlFileDocSink::CXmlFileDocSink(const string& strXmlInstanceFile):
+     _strXmlInstanceFile(strXmlInstanceFile)
 {
-public:
-    CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlComposer();
+}
 
-    // open / close
-    virtual bool open();
-    virtual bool close();
+bool CXmlFileDocSink::doProcess(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext)
+{
+    // Write file (formatted)
+    if (xmlSaveFormatFileEnc(_strXmlInstanceFile.c_str(), xmlDocSource.getDoc(), "UTF-8", 1) == -1) {
 
-    // Composing contents
-    void compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion);
+        serializingContext.setError("Could not write file " + _strXmlInstanceFile);
 
-private:
-    static string getTimeAsString();
-};
+        return false;
+    }
+    return true;
+}
 
diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlFileDocSink.h
similarity index 64%
copy from xmlserializer/XmlComposer.h
copy to xmlserializer/XmlFileDocSink.h
index 9e50de8..d06365a 100644
--- a/xmlserializer/XmlComposer.h
+++ b/xmlserializer/XmlFileDocSink.h
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,38 +12,29 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
+
 #pragma once
 
-#include "XmlSerializer.h"
-#include "XmlSource.h"
+#include "XmlDocSink.h"
 
-struct _xmlDoc;
-struct _xmlNode;
-
-class CXmlComposer : public CXmlSerializer
+class CXmlFileDocSink : public CXmlDocSink
 {
 public:
-    CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlComposer();
-
-    // open / close
-    virtual bool open();
-    virtual bool close();
-
-    // Composing contents
-    void compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion);
+    CXmlFileDocSink(const string& strXmlInstanceFile);
 
 private:
-    static string getTimeAsString();
-};
+    // Source processing
+    virtual bool doProcess(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext);
 
+    // Instance file
+    string _strXmlInstanceFile;
+};
diff --git a/xmlserializer/XmlFileDocSource.cpp b/xmlserializer/XmlFileDocSource.cpp
new file mode 100644
index 0000000..c8a0837
--- /dev/null
+++ b/xmlserializer/XmlFileDocSource.cpp
@@ -0,0 +1,151 @@
+/*
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * CREATED: 2012-08-10
+ */
+
+#include "XmlFileDocSource.h"
+#include <libxml/parser.h>
+#include <libxml/xmlschemas.h>
+
+#define base CXmlDocSource
+
+
+
+CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, const string& strRootElementName, const string& strNameAttrituteName) :
+        base(xmlReadFile(strXmlInstanceFile.c_str(), NULL, 0)), _strXmlInstanceFile(strXmlInstanceFile), _strXmlSchemaFile(strXmlSchemaFile), _strRootElementType(strRootElementType), _strRootElementName(strRootElementName), _strNameAttrituteName(strNameAttrituteName), _bNameCheck(true)
+{
+}
+
+CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType) :
+        base(xmlReadFile(strXmlInstanceFile.c_str(), NULL, 0)), _strXmlInstanceFile(strXmlInstanceFile), _strXmlSchemaFile(strXmlSchemaFile), _strRootElementType(strRootElementType), _strRootElementName(""), _strNameAttrituteName(""), _bNameCheck(false)
+{
+}
+
+bool CXmlFileDocSource::populate(CXmlSerializingContext& serializingContext)
+{
+    // Check that the doc has been created
+    if (!_pDoc) {
+
+        serializingContext.setError("Could not parse file " + _strXmlInstanceFile);
+
+        return false;
+    }
+
+    // Validate
+    if (!isInstanceDocumentValid()) {
+
+        serializingContext.setError("Document " + _strXmlInstanceFile + " is not valid");
+
+        return false;
+    }
+
+    // Check Root element type
+    if (getRootElementName() != _strRootElementType) {
+
+        serializingContext.setError("Error: Wrong XML structure file " + _strXmlInstanceFile);
+        serializingContext.appendLineToError("Root Element " + getRootElementName() + " mismatches expected type " + _strRootElementType);
+
+        return false;
+    }
+
+    // Check Root element name attribute (if any)
+    if (_bNameCheck) {
+
+        string strRootElementNameCheck = getRootElementAttributeString(_strNameAttrituteName);
+
+        if (!_strRootElementName.empty() && strRootElementNameCheck != _strRootElementName) {
+
+            serializingContext.setError("Error: Wrong XML structure file " + _strXmlInstanceFile);
+            serializingContext.appendLineToError(_strRootElementType + " element " + _strRootElementName + " mismatches expected " + _strRootElementType + " type " + strRootElementNameCheck);
+
+            return false;
+        }
+    }
+
+    return true;
+}
+
+bool CXmlFileDocSource::isInstanceDocumentValid()
+{
+#ifdef LIBXML_SCHEMAS_ENABLED
+    xmlDocPtr pSchemaDoc = xmlReadFile(_strXmlSchemaFile.c_str(), NULL, XML_PARSE_NONET);
+
+    if (!pSchemaDoc) {
+        // Unable to load Schema
+        return false;
+    }
+
+    xmlSchemaParserCtxtPtr pParserCtxt = xmlSchemaNewDocParserCtxt(pSchemaDoc);
+
+    if (!pParserCtxt) {
+
+        // Unable to create schema context
+        xmlFreeDoc(pSchemaDoc);
+        return false;
+    }
+
+    // Get Schema
+    xmlSchemaPtr pSchema = xmlSchemaParse(pParserCtxt);
+
+    if (!pSchema) {
+
+        // Invalid Schema
+        xmlSchemaFreeParserCtxt(pParserCtxt);
+        xmlFreeDoc(pSchemaDoc);
+        return false;
+    }
+    xmlSchemaValidCtxtPtr pValidationCtxt = xmlSchemaNewValidCtxt(pSchema);
+
+    if (!pValidationCtxt) {
+
+        // Unable to create validation context
+        xmlSchemaFree(pSchema);
+        xmlSchemaFreeParserCtxt(pParserCtxt);
+        xmlFreeDoc(pSchemaDoc);
+        return false;
+    }
+
+    xmlSetStructuredErrorFunc(this, schemaValidityStructuredErrorFunc);
+    //xmlSchemaSetValidErrors(pValidationCtxt, schemaValidityErrorFunc, schemaValidityWarningFunc, NULL);
+
+    bool isDocValid = xmlSchemaValidateDoc(pValidationCtxt, _pDoc) == 0;
+
+    xmlSchemaFreeValidCtxt(pValidationCtxt);
+    xmlSchemaFree(pSchema);
+    xmlSchemaFreeParserCtxt(pParserCtxt);
+    xmlFreeDoc(pSchemaDoc);
+
+    return isDocValid;
+#else
+    return true;
+#endif
+}
+
+void CXmlFileDocSource::schemaValidityStructuredErrorFunc(void* pUserData, _xmlError* pError)
+{
+    (void)pUserData;
+
+#ifdef LIBXML_SCHEMAS_ENABLED
+    // Display message
+    puts(pError->message);
+#endif
+}
diff --git a/xmlserializer/XmlFileDocSource.h b/xmlserializer/XmlFileDocSource.h
new file mode 100644
index 0000000..3274b29
--- /dev/null
+++ b/xmlserializer/XmlFileDocSource.h
@@ -0,0 +1,63 @@
+/*
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * CREATED: 2012-08-10
+ */
+
+#pragma once
+
+#include "XmlDocSource.h"
+#include "XmlSource.h"
+
+struct _xmlError;
+
+class CXmlFileDocSource : public CXmlDocSource
+{
+public:
+    CXmlFileDocSource(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, const string& strRootElementName, const string& strNameAttrituteName);
+
+    CXmlFileDocSource(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType);
+
+
+    // CXmlDocSource method implemented
+    virtual bool populate(CXmlSerializingContext& serializingContext);
+
+private:
+
+    // Validation of the document with the xsd file
+    bool isInstanceDocumentValid();
+
+    static void schemaValidityStructuredErrorFunc(void* pUserData, _xmlError* pError);
+
+    // Instance file
+    string _strXmlInstanceFile;
+    // Schema file
+    string _strXmlSchemaFile;
+    // Element type info
+    string _strRootElementType;
+    // Element name info
+    string _strRootElementName;
+    // Element name attribute info
+    string _strNameAttrituteName;
+
+    bool _bNameCheck;
+
+};
diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlMemoryDocSink.cpp
similarity index 62%
copy from xmlserializer/XmlComposer.h
copy to xmlserializer/XmlMemoryDocSink.cpp
index 9e50de8..430ae1d 100644
--- a/xmlserializer/XmlComposer.h
+++ b/xmlserializer/XmlMemoryDocSink.cpp
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,38 +12,33 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
-#pragma once
 
-#include "XmlSerializer.h"
-#include "XmlSource.h"
+#include "XmlMemoryDocSink.h"
 
-struct _xmlDoc;
-struct _xmlNode;
+#define base CXmlDocSink
 
-class CXmlComposer : public CXmlSerializer
+CXmlMemoryDocSink::CXmlMemoryDocSink(IXmlSink* pXmlSink):
+        _pXmlSink(pXmlSink)
 {
-public:
-    CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlComposer();
+}
 
-    // open / close
-    virtual bool open();
-    virtual bool close();
+bool CXmlMemoryDocSink::doProcess(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext)
+{
 
-    // Composing contents
-    void compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion);
+    CXmlElement docElement;
+    xmlDocSource.getRootElement(docElement);
 
-private:
-    static string getTimeAsString();
-};
+    // Load the structure from the XML Sink
+    _pXmlSink->fromXml(docElement, serializingContext);
 
+    return true;
+}
diff --git a/xmlserializer/XmlParser.h b/xmlserializer/XmlMemoryDocSink.h
similarity index 65%
rename from xmlserializer/XmlParser.h
rename to xmlserializer/XmlMemoryDocSink.h
index 03defd9..9bc2acf 100644
--- a/xmlserializer/XmlParser.h
+++ b/xmlserializer/XmlMemoryDocSink.h
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,37 +12,30 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
+
 #pragma once
 
-#include "XmlSerializer.h"
+#include "XmlDocSink.h"
 #include "XmlSink.h"
 
-struct _xmlError;
-
-class CXmlParser : public CXmlSerializer
+class CXmlMemoryDocSink : public CXmlDocSink
 {
 public:
-    CXmlParser(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlParser();
-
-    // Parsing file
-    virtual bool open();
-
-    // Parsing contents
-    bool parse(IXmlSink* pXmlSink);
+    CXmlMemoryDocSink(IXmlSink* pXmlSink);
 
 private:
-    // Validity checks
-    bool isInstanceDocumentValid();
-    static void schemaValidityStructuredErrorFunc(void* pUserData, _xmlError* pError);
+    // Source processing
+    virtual bool doProcess(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext);
+
+    // Xml Sink
+    IXmlSink* _pXmlSink;
 };
diff --git a/xmlserializer/XmlMemoryDocSource.cpp b/xmlserializer/XmlMemoryDocSource.cpp
new file mode 100644
index 0000000..9f1c5ad
--- /dev/null
+++ b/xmlserializer/XmlMemoryDocSource.cpp
@@ -0,0 +1,92 @@
+/*
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * CREATED: 2012-08-10
+ */
+
+#include "XmlMemoryDocSource.h"
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#define base CXmlDocSource
+
+CXmlMemoryDocSource::CXmlMemoryDocSource(const IXmlSource* pXmlSource, const string& strRootElementType, const string& strXmlSchemaFile, const string& strProduct, const string& strVersion):
+     base(xmlNewDoc(BAD_CAST "1.0"), xmlNewNode(NULL, BAD_CAST strRootElementType.c_str())), _pXmlSource(pXmlSource), _strXmlSchemaFile(strXmlSchemaFile), _bWithHeader(true), _strProduct(strProduct), _strVersion(strVersion)
+{
+    init();
+}
+
+CXmlMemoryDocSource::CXmlMemoryDocSource(const IXmlSource* pXmlSource, const string& strRootElementType):
+    base(xmlNewDoc(BAD_CAST "1.0"), xmlNewNode(NULL, BAD_CAST strRootElementType.c_str())), _pXmlSource(pXmlSource), _bWithHeader(false)
+{
+    init();
+}
+
+void CXmlMemoryDocSource::init()
+{
+#ifdef LIBXML_TREE_ENABLED
+
+    // Assign it to document
+    xmlDocSetRootElement(_pDoc, _pRootNode);
+#endif
+}
+
+bool CXmlMemoryDocSource::populate(CXmlSerializingContext& serializingContext)
+{
+#ifndef LIBXML_TREE_ENABLED
+    serializingContext.setError("XML file exporting feature unsupported on this image. This easiest way to activate it is to do a global recompilation with LIBXML_TREE_ENABLED compiler switch set");
+
+    return false;
+#endif
+
+    // Create Xml element with the Doc
+     CXmlElement docElement(_pRootNode);
+
+    if (_bWithHeader) {
+
+        // Schema namespace
+        docElement.setAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
+
+        // Schema location
+        docElement.setAttributeString("xsi:noNamespaceSchemaLocation", _strXmlSchemaFile);
+
+        // Comment for date/time
+        docElement.setComment(string(" Exported on ") + getTimeAsString() + " from " + _strProduct + " version " + _strVersion + " ");
+    }
+
+    // Compose the xml document
+    _pXmlSource->toXml(docElement, serializingContext);
+
+    return true;
+}
+
+string CXmlMemoryDocSource::getTimeAsString()
+{
+    char acBuf[200];
+    time_t t;
+    struct tm *tmp;
+    t = time(NULL);
+    tmp = localtime(&t);
+
+    strftime(acBuf, sizeof(acBuf), "%F, %T", tmp);
+
+    return acBuf;
+}
diff --git a/xmlserializer/XmlMemoryDocSource.h b/xmlserializer/XmlMemoryDocSource.h
new file mode 100644
index 0000000..c507282
--- /dev/null
+++ b/xmlserializer/XmlMemoryDocSource.h
@@ -0,0 +1,59 @@
+/*
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * CREATED: 2012-08-10
+ */
+
+#pragma once
+
+#include "XmlDocSource.h"
+#include "XmlSource.h"
+
+class CXmlMemoryDocSource : public CXmlDocSource
+{
+public:
+    CXmlMemoryDocSource(const IXmlSource* pXmlSource, const string& strRootElementType, const string& strXmlSchemaFile, const string& strProduct, const string& strVersion);
+
+    CXmlMemoryDocSource(const IXmlSource* pXmlSource, const string& strRootElementType);
+
+    virtual bool populate(CXmlSerializingContext& serializingContext);
+private:
+
+    // initialize root element
+    void init();
+
+    // Xml Source
+    const IXmlSource* _pXmlSource;
+
+    // Schema file
+    string _strXmlSchemaFile;
+
+    // Boolean used to specify if a header should be added in the Xml Doc
+    bool _bWithHeader;
+
+    // Product and version info
+    string _strProduct;
+    string _strVersion;
+
+    // Get the current system time
+    static string getTimeAsString();
+
+};
diff --git a/xmlserializer/XmlParser.cpp b/xmlserializer/XmlParser.cpp
deleted file mode 100644
index af26346..0000000
--- a/xmlserializer/XmlParser.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/* 
- * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
- * Corporation All Rights Reserved.
- * 
- * The source code contained or described herein and all documents related to
- * the source code ("Material") are owned by Intel Corporation or its suppliers
- * or licensors. Title to the Material remains with Intel Corporation or its
- * suppliers and licensors. The Material contains trade secrets and proprietary
- * and confidential information of Intel or its suppliers and licensors. The
- * Material is protected by worldwide copyright and trade secret laws and
- * treaty provisions. No part of the Material may be used, copied, reproduced,
- * modified, published, uploaded, posted, transmitted, distributed, or
- * disclosed in any way without Intel’s prior express written permission.
- * 
- * No license under any patent, copyright, trade secret or other intellectual
- * property right is granted to or conferred upon you by disclosure or delivery
- * of the Materials, either expressly, by implication, inducement, estoppel or
- * otherwise. Any license under such intellectual property rights must be
- * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
- */
-#include "XmlParser.h"
-#include <stdio.h>
-#include <stdarg.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xmlschemas.h>
-
-#define base CXmlSerializer
-
-
-CXmlParser::CXmlParser(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext) :
-    base(strXmlInstanceFile, strXmlSchemaFile, strRootElementType, serializingContext)
-{
-}
-
-CXmlParser::~CXmlParser()
-{
-}
-
-void CXmlParser::schemaValidityStructuredErrorFunc(void* pUserData, _xmlError* pError)
-{
-    (void)pUserData;
-
-#ifdef LIBXML_SCHEMAS_ENABLED
-    // Display message
-    puts(pError->message);
-#endif
-}
-
-bool CXmlParser::isInstanceDocumentValid()
-{
-#ifdef LIBXML_SCHEMAS_ENABLED
-    xmlDocPtr pSchemaDoc = xmlReadFile(_strXmlSchemaFile.c_str(), NULL, XML_PARSE_NONET);
-
-    if (!pSchemaDoc) {
-        // Unable to load Schema
-        return false;
-    }
-
-    xmlSchemaParserCtxtPtr pParserCtxt = xmlSchemaNewDocParserCtxt(pSchemaDoc);
-
-    if (!pParserCtxt) {
-
-        // Unable to create schema context
-        xmlFreeDoc(pSchemaDoc);
-        return false;
-    }
-
-    // Get Schema
-    xmlSchemaPtr pSchema = xmlSchemaParse(pParserCtxt);
-
-    if (!pSchema) {
-
-        // Invalid Schema
-        xmlSchemaFreeParserCtxt(pParserCtxt);
-        xmlFreeDoc(pSchemaDoc);
-        return false;
-    }
-    xmlSchemaValidCtxtPtr pValidationCtxt = xmlSchemaNewValidCtxt(pSchema);
-
-    if (!pValidationCtxt) {
-
-        // Unable to create validation context
-        xmlSchemaFree(pSchema);
-        xmlSchemaFreeParserCtxt(pParserCtxt);
-        xmlFreeDoc(pSchemaDoc);
-        return false;
-    }
-
-    xmlSetStructuredErrorFunc(this, schemaValidityStructuredErrorFunc);
-    //xmlSchemaSetValidErrors(pValidationCtxt, schemaValidityErrorFunc, schemaValidityWarningFunc, NULL);
-
-    bool isDocValid = xmlSchemaValidateDoc(pValidationCtxt, _pDoc) == 0;
-
-    xmlSchemaFreeValidCtxt(pValidationCtxt);
-    xmlSchemaFree(pSchema);
-    xmlSchemaFreeParserCtxt(pParserCtxt);
-    xmlFreeDoc(pSchemaDoc);
-
-    return isDocValid;
-#else
-    return true;
-#endif
-}
-
-bool CXmlParser::open()
-{
-    // Parse the file and get the DOM
-    _pDoc = xmlReadFile(_strXmlInstanceFile.c_str(), NULL, 0);
-
-    if (!_pDoc) {
-
-        _serializingContext.setError("Could not parse file " + _strXmlInstanceFile);
-
-        return false;
-    }
-    // Validate
-    if (!isInstanceDocumentValid()) {
-
-        _serializingContext.setError("Document " + _strXmlInstanceFile + " is not valid");
-
-        // Free XML doc
-        xmlFreeDoc(_pDoc);
-
-        _pDoc = NULL;
-
-        return false;
-    }
-
-    // Get the root element node
-    _pRootNode = xmlDocGetRootElement(_pDoc);
-
-    // Check Root element type
-    if (getRootElementName() != _strRootElementType) {
-
-        _serializingContext.setError("Error: Wrong XML structure file " + _strXmlInstanceFile);
-        _serializingContext.appendLineToError("Root Element " + getRootElementName() + " mismatches expected type " + _strRootElementType);
-
-        return false;
-    }
-
-    return base::open();
-}
-
-bool CXmlParser::parse(IXmlSink* pXmlSink)
-{
-    // Parse document
-    CXmlElement topMostElement(_pRootNode);
-
-    return pXmlSink->fromXml(topMostElement, _serializingContext);
-}
-
diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlStringDocSink.cpp
similarity index 62%
copy from xmlserializer/XmlComposer.h
copy to xmlserializer/XmlStringDocSink.cpp
index 9e50de8..a96a1ed 100644
--- a/xmlserializer/XmlComposer.h
+++ b/xmlserializer/XmlStringDocSink.cpp
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,38 +12,38 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
-#pragma once
 
-#include "XmlSerializer.h"
-#include "XmlSource.h"
+#include "XmlStringDocSink.h"
+#include <libxml/parser.h>
 
-struct _xmlDoc;
-struct _xmlNode;
+#define base CXmlDocSink
 
-class CXmlComposer : public CXmlSerializer
+CXmlStringDocSink::CXmlStringDocSink(string& strResult):
+      _strResult(strResult)
 {
-public:
-    CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlComposer();
+}
 
-    // open / close
-    virtual bool open();
-    virtual bool close();
+bool CXmlStringDocSink::doProcess(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext)
+{
+    (void)serializingContext;
 
-    // Composing contents
-    void compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion);
+    xmlChar* pcDumpedDoc = NULL;
 
-private:
-    static string getTimeAsString();
-};
+    int iSize;
+    xmlDocDumpFormatMemoryEnc(xmlDocSource.getDoc(), &pcDumpedDoc, &iSize, "UTF-8", 1);
 
+    _strResult.append((const char*)pcDumpedDoc);
+
+    xmlFree(pcDumpedDoc);
+
+    return true;
+}
diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlStringDocSink.h
similarity index 65%
rename from xmlserializer/XmlComposer.h
rename to xmlserializer/XmlStringDocSink.h
index 9e50de8..2d777fa 100644
--- a/xmlserializer/XmlComposer.h
+++ b/xmlserializer/XmlStringDocSink.h
@@ -1,8 +1,8 @@
-/* 
+/*
  * INTEL CONFIDENTIAL
- * Copyright © 2011 Intel 
+ * Copyright © 2011 Intel
  * Corporation All Rights Reserved.
- * 
+ *
  * The source code contained or described herein and all documents related to
  * the source code ("Material") are owned by Intel Corporation or its suppliers
  * or licensors. Title to the Material remains with Intel Corporation or its
@@ -12,38 +12,31 @@
  * treaty provisions. No part of the Material may be used, copied, reproduced,
  * modified, published, uploaded, posted, transmitted, distributed, or
  * disclosed in any way without Intel’s prior express written permission.
- * 
+ *
  * No license under any patent, copyright, trade secret or other intellectual
  * property right is granted to or conferred upon you by disclosure or delivery
  * of the Materials, either expressly, by implication, inducement, estoppel or
  * otherwise. Any license under such intellectual property rights must be
  * express and approved by Intel in writing.
- * 
- * CREATED: 2011-06-01
- * UPDATED: 2011-07-27
+ *
+ * CREATED: 2012-08-10
  */
+
 #pragma once
 
-#include "XmlSerializer.h"
+#include "XmlDocSink.h"
 #include "XmlSource.h"
 
-struct _xmlDoc;
-struct _xmlNode;
-
-class CXmlComposer : public CXmlSerializer
+class CXmlStringDocSink : public CXmlDocSink
 {
 public:
-    CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
-    virtual ~CXmlComposer();
-
-    // open / close
-    virtual bool open();
-    virtual bool close();
-
-    // Composing contents
-    void compose(const IXmlSource* pXmlSource, const string& strProduct, const string& strVersion);
+    CXmlStringDocSink(string& strResult);
 
 private:
-    static string getTimeAsString();
+    // Source processing
+    virtual bool doProcess(CXmlDocSource& xmlDocSource, CXmlSerializingContext& serializingContext);
+
+    // Result string containing the XML informations
+    string& _strResult;
 };