SOLR-92: better handling of Attributes in DOMUtils.getText

git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@489961 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2006-12-24 01:10:00 +00:00
parent c19acfe50f
commit e44e51ece0
2 changed files with 17 additions and 1 deletions

View File

@ -46,6 +46,9 @@ Optimizations
Bug Fixes
1. SOLR-87: Parsing of synonym files did not correctly handle escaped
whitespace such as \r\n\t\b\f. (yonik)
2. SOLR-92: DOMUtils.getText (used when parsing config files) did not
work properly with many DOM implementations when dealing with
"Attributes". (Ryan McKinley via hossman)
Other Changes
1.

View File

@ -189,7 +189,6 @@ public class DOMUtil {
switch (type) {
case Node.ELEMENT_NODE: /* fall through */
case Node.ATTRIBUTE_NODE: /* fall through */
case Node.ENTITY_NODE: /* fall through */
case Node.ENTITY_REFERENCE_NODE: /* fall through */
case Node.DOCUMENT_FRAGMENT_NODE:
@ -204,6 +203,20 @@ public class DOMUtil {
}
break;
case Node.ATTRIBUTE_NODE: /* fall through */
/* Putting Attribute nodes in this section does not exactly
match the definition of how textContent should behave
according to the DOM Level-3 Core documentation - which
specifies that the Attr's children should have their
textContent concated (Attr's can have a single child which
is either Text node or an EntityRefrence). In practice,
DOM implementations do not seem to use child nodes of
Attributes, storing the "text" directly as the nodeValue.
Fortunately, the DOM Spec indicates that when Attr.nodeValue
is read, it should return the nodeValue from the child Node,
so this approach should work both for strict implementations,
and implementations actually encountered.
*/
case Node.TEXT_NODE: /* fall through */
case Node.CDATA_SECTION_NODE: /* fall through */
case Node.COMMENT_NODE: /* fall through */