Commit 4117b095 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Parse with XML_PARSE_NOENT to resolve XML entities.

Fix reader to properly add content for DataStructure deprecated items.
Move whitespace trimming to reader where it is more convenient since
it can replace a check for the content being all whitespace.
parent 65ac92d8
......@@ -21,7 +21,6 @@
/* */
/*****************************************************************************/
#include <boost/algorithm/string/trim.hpp>
#include <boost/assign.hpp>
#include <boost/tokenizer.hpp>
#include <limits>
......@@ -1010,6 +1009,7 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
const std::vector<shared_ptr<XdmfItem> > & childItems,
const XdmfCoreReader * const reader)
{
// This inserts any XdmfInformation in childItems into the object.
XdmfItem::populateItem(itemProperties, childItems, reader);
......@@ -1031,8 +1031,7 @@ XdmfArray::populateItem(const std::map<std::string, std::string> & itemPropertie
unsigned int contentIndex;
// trim content of whitespace
const std::string contentVal = boost::algorithm::trim_copy(content->second);
const std::string & contentVal = content->second;
std::vector<std::string> contentVals;
......
......@@ -24,10 +24,11 @@
#include <libxml/uri.h>
#include <libxml/xpointer.h>
#include <libxml/xmlreader.h>
#include "boost/tokenizer.hpp"
#include <boost/algorithm/string/trim.hpp>
#include <boost/tokenizer.hpp>
#include <cstring>
#include <map>
#include <sstream>
#include <cstring>
#include <utility>
#include "XdmfArray.hpp"
#include "XdmfArrayType.hpp"
......@@ -79,7 +80,7 @@ public:
mXMLDir = mXMLDir.substr(0, index + 1);
}
mDocument = xmlReadFile(filePath.c_str(), NULL, 0);
mDocument = xmlReadFile(filePath.c_str(), NULL, XML_PARSE_NOENT);
if(mDocument == NULL) {
try {
......@@ -205,7 +206,7 @@ public:
readSingleNode(const xmlNodePtr currNode,
std::vector<shared_ptr<XdmfItem> > & myItems)
{
// Check to see if the node is already in the Xpath
// Check to see if the node is already in the XPath Map (seen previously)
std::map<xmlNodePtr, shared_ptr<XdmfItem> >::const_iterator iter =
mXPathMap.find(currNode);
// If it is grab it from the previously stored items
......@@ -213,29 +214,19 @@ public:
myItems.push_back(iter->second);
}
else {
// Otherwise, generate it from the node
// Otherwise, generate a new Item from the node
std::map<std::string, std::string> itemProperties;
xmlNodePtr childNode = currNode->children;
if (XdmfArray::ItemTag.compare((char *)currNode->name) == 0) {
if (XdmfArray::ItemTag.compare((char *)currNode->name) == 0 ||
strcmp("DataStructure", (char *)currNode->name) == 0) {
while(childNode != NULL) {
if(childNode->type == XML_TEXT_NODE && childNode->content) {
const char * content = (char*)childNode->content;
// Determine if content is whitespace
bool whitespace = true;
const char * contentPtr = content;
// Step through to end of pointer
while(contentPtr != NULL) {
// If not a whitespace character, break
if(!isspace(*contentPtr++)) {
whitespace = false;
break;
}
}
std::string content((char *)childNode->content);
boost::algorithm::trim(content);
if(!whitespace) {
if(content.size() != 0) {
itemProperties.insert(std::make_pair("Content", content));
itemProperties.insert(std::make_pair("XMLDir", mXMLDir));
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment