Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * INTEL CONFIDENTIAL |
| 3 | * Copyright © 2011 Intel |
| 4 | * Corporation All Rights Reserved. |
| 5 | * |
| 6 | * The source code contained or described herein and all documents related to |
| 7 | * the source code ("Material") are owned by Intel Corporation or its suppliers |
| 8 | * or licensors. Title to the Material remains with Intel Corporation or its |
| 9 | * suppliers and licensors. The Material contains trade secrets and proprietary |
| 10 | * and confidential information of Intel or its suppliers and licensors. The |
| 11 | * Material is protected by worldwide copyright and trade secret laws and |
| 12 | * treaty provisions. No part of the Material may be used, copied, reproduced, |
| 13 | * modified, published, uploaded, posted, transmitted, distributed, or |
| 14 | * disclosed in any way without Intel’s prior express written permission. |
| 15 | * |
| 16 | * No license under any patent, copyright, trade secret or other intellectual |
| 17 | * property right is granted to or conferred upon you by disclosure or delivery |
| 18 | * of the Materials, either expressly, by implication, inducement, estoppel or |
| 19 | * otherwise. Any license under such intellectual property rights must be |
| 20 | * express and approved by Intel in writing. |
| 21 | * |
| 22 | * CREATED: 2012-08-10 |
| 23 | */ |
| 24 | |
| 25 | #include "XmlFileDocSource.h" |
| 26 | #include <libxml/parser.h> |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 27 | |
| 28 | #define base CXmlDocSource |
| 29 | |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame^] | 30 | CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile, |
| 31 | const string& strXmlSchemaFile, |
| 32 | const string& strRootElementType, |
| 33 | const string& strRootElementName, |
| 34 | const string& strNameAttrituteName) : |
| 35 | base(xmlReadFile(strXmlInstanceFile.c_str(),NULL, 0), |
| 36 | strXmlSchemaFile, |
| 37 | strRootElementType, |
| 38 | strRootElementName, |
| 39 | strNameAttrituteName), |
| 40 | _strXmlInstanceFile(strXmlInstanceFile) |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 41 | { |
| 42 | } |
| 43 | |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame^] | 44 | CXmlFileDocSource::CXmlFileDocSource(const string& strXmlInstanceFile, |
| 45 | const string& strXmlSchemaFile, |
| 46 | const string& strRootElementType) : |
| 47 | base(xmlReadFile(strXmlInstanceFile.c_str(), NULL, 0), |
| 48 | strXmlSchemaFile, |
| 49 | strRootElementType), |
| 50 | _strXmlInstanceFile(strXmlInstanceFile) |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 51 | { |
| 52 | } |
| 53 | |
Frédéric Boisnard | a409daa | 2012-10-18 18:20:03 +0200 | [diff] [blame] | 54 | bool CXmlFileDocSource::isParsable(CXmlSerializingContext& serializingContext) const |
| 55 | { |
| 56 | // Check that the doc has been created |
| 57 | if (!_pDoc) { |
| 58 | |
| 59 | serializingContext.setError("Could not parse file " + _strXmlInstanceFile); |
| 60 | |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | return true; |
| 65 | } |
| 66 | |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame^] | 67 | bool CXmlFileDocSource::populate(CXmlSerializingContext& serializingContext) |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 68 | { |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame^] | 69 | if (!base::validate(serializingContext)) { |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 70 | |
Georges-Henri Baron | cec86c1 | 2012-09-04 17:30:28 +0200 | [diff] [blame^] | 71 | // Add the file's name in the error message |
| 72 | serializingContext.appendLineToError("File : " + _strXmlInstanceFile); |
| 73 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 74 | return false; |
| 75 | } |
| 76 | |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 77 | return true; |
Georges-Henri Baron | 326a31d | 2012-06-28 12:05:09 +0200 | [diff] [blame] | 78 | } |