Commit 86ae3272 authored by Kenneth Leiter's avatar Kenneth Leiter
Browse files

BUG: Fix bug found by Di when dealing with text nodes in XML.

The code to deal with "Content" stored in XML Text Nodes was previously
rewritten to avoid use of xmlNodeGetContent() which recursively combines
all children node contents to the content of the current node, which was
undesired behavior. I was rewritten to find the first text node and return
the content of that node, but this was insufficient as sometimes the first
text node is whitespace. The code now finds the first text node containing
content, which works for all Xdmf and NetDMF files we have come across.
parent 8c860bb4
......@@ -140,11 +140,25 @@ public:
xmlNodePtr childNode = currNode->children;
while(childNode != NULL) {
if(childNode->type == XML_TEXT_NODE) {
xmlChar * content = childNode->content;
itemProperties["Content"] = (char*)content;
itemProperties["XMLDir"] = mXMLDir;
break;
if(childNode->type == XML_TEXT_NODE && childNode->content) {
const char * content = (char*)childNode->content;
// determine if content is whitespace
const size_t contentSize = strlen(content);
bool whitespace = true;
for(int i=0; i<contentSize; ++i) {
if(!isspace(content[i])) {
whitespace = false;
break;
}
}
if(!whitespace) {
itemProperties["Content"] = content;
itemProperties["XMLDir"] = mXMLDir;
break;
}
}
childNode = childNode->next;
}
......
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