[cpp-xmltooling] branch master updated: CPPXT-128 - Rework text node handling and disable comments.
Scott Cantor
cantor.2 at osu.edu
Tue Feb 27 11:45:55 EST 2018
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch master
in repository cpp-xmltooling.
View the commit online:
http://git.shibboleth.net/view/?p=cpp-xmltooling.git;a=commit;h=74ec6fa833f46a84486a97c491e391fb8c48f1ea
The following commit(s) were added to refs/heads/master by this push:
new 74ec6fa CPPXT-128 - Rework text node handling and disable comments.
74ec6fa is described below
commit 74ec6fa833f46a84486a97c491e391fb8c48f1ea
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Feb 27 11:45:44 2018 -0500
CPPXT-128 - Rework text node handling and disable comments.
---
xmltooling/AbstractComplexElement.cpp | 16 +++++++++++++++-
xmltooling/AbstractSimpleElement.cpp | 22 ++++++++++++++--------
xmltooling/io/AbstractXMLObjectUnmarshaller.cpp | 5 +++--
xmltooling/util/ParserPool.cpp | 1 +
4 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/xmltooling/AbstractComplexElement.cpp b/xmltooling/AbstractComplexElement.cpp
index 361ba2f..a04ef88 100644
--- a/xmltooling/AbstractComplexElement.cpp
+++ b/xmltooling/AbstractComplexElement.cpp
@@ -93,5 +93,19 @@ void AbstractComplexElement::setTextContent(const XMLCh* value, unsigned int pos
m_text.push_back(nullptr);
++size;
}
- m_text[position] = prepareForAssignment(m_text[position], value);
+
+ // Merge if necessary.
+ if (value && *value) {
+ if (!m_text[position] || !*m_text[position]) {
+ m_text[position] = prepareForAssignment(m_text[position], value);
+ }
+ else {
+ XMLSize_t initialLen = XMLString::stringLen(m_text[position]);
+ XMLCh* merged = new XMLCh[initialLen + XMLString::stringLen(value) + 1];
+ auto_arrayptr<XMLCh> janitor(merged);
+ XMLString::copyString(merged, m_text[position]);
+ XMLString::catString(merged + initialLen, value);
+ m_text[position] = prepareForAssignment(m_text[position], merged);
+ }
+ }
}
diff --git a/xmltooling/AbstractSimpleElement.cpp b/xmltooling/AbstractSimpleElement.cpp
index 5782e3b..9e4d4a2 100644
--- a/xmltooling/AbstractSimpleElement.cpp
+++ b/xmltooling/AbstractSimpleElement.cpp
@@ -77,12 +77,18 @@ void AbstractSimpleElement::setTextContent(const XMLCh* value, unsigned int posi
if (position > 0)
throw XMLObjectException("Cannot set text content in simple element at position > 0.");
- // We overwrite the "one" piece of Text content if:
- // - the new value is null
- // - there is no existing value
- // - the old value is all whitespace
- // If there's a non-whitespace value set, we leave it alone unless we're clearing it with a null.
-
- if (!value || !m_value || XMLChar1_0::isAllSpaces(m_value, XMLString::stringLen(m_value)))
- m_value=prepareForAssignment(m_value, value);
+ // Merge if necessary.
+ if (value && *value) {
+ if (!m_value || !*m_value) {
+ m_value = prepareForAssignment(m_value, value);
+ }
+ else {
+ XMLSize_t initialLen = XMLString::stringLen(m_value);
+ XMLCh* merged = new XMLCh[initialLen + XMLString::stringLen(value) + 1];
+ auto_arrayptr<XMLCh> janitor(merged);
+ XMLString::copyString(merged, m_value);
+ XMLString::catString(merged + initialLen, value);
+ m_value = prepareForAssignment(m_value, merged);
+ }
+ }
}
diff --git a/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp b/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp
index 487348e..eac4187 100644
--- a/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp
+++ b/xmltooling/io/AbstractXMLObjectUnmarshaller.cpp
@@ -206,8 +206,9 @@ void AbstractXMLObjectUnmarshaller::unmarshallContent(const DOMElement* domEleme
else if (childNode->getNodeType() == DOMNode::TEXT_NODE || childNode->getNodeType() == DOMNode::CDATA_SECTION_NODE) {
m_log.debug("processing text content at position (%d)", position);
setTextContent(childNode->getNodeValue(), position);
- } else if (childNode->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE || childNode->getNodeType() == DOMNode::ENTITY_NODE) {
- throw UnmarshallingException("Unmarshaller found Entity/Reference node.");
+ }
+ else if (childNode->getNodeType() != DOMNode::ATTRIBUTE_NODE) {
+ throw UnmarshallingException("Unmarshaller found unsupported node type.");
}
childNode = childNode->getNextSibling();
diff --git a/xmltooling/util/ParserPool.cpp b/xmltooling/util/ParserPool.cpp
index c2c1aef..5d96b66 100644
--- a/xmltooling/util/ParserPool.cpp
+++ b/xmltooling/util/ParserPool.cpp
@@ -370,6 +370,7 @@ DOMLSParser* ParserPool::createBuilder()
parser->getDomConfig()->setParameter(XMLUni::fgXercesUserAdoptsDOMDocument, true);
parser->getDomConfig()->setParameter(XMLUni::fgXercesDisableDefaultEntityResolution, true);
parser->getDomConfig()->setParameter(XMLUni::fgDOMDisallowDoctype, true);
+ parser->getDomConfig()->setParameter(XMLUni::fgDOMComments, false);
parser->getDomConfig()->setParameter(XMLUni::fgDOMResourceResolver, dynamic_cast<DOMLSResourceResolver*>(this));
parser->getDomConfig()->setParameter(XMLUni::fgXercesSecurityManager, m_security.get());
return parser;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list