* Avoid duplicate child-text-to-property assignment.
* Parse children in sparse mode even if we don't convert the element itself. * Avoid assigning element text as property "text" in sparse mode.
This commit is contained in:
parent
d41c6d5657
commit
48a7b536a0
1 changed files with 11 additions and 6 deletions
|
@ -161,10 +161,10 @@ public class XmlConverter implements XmlConstants {
|
||||||
if (dot > -1) {
|
if (dot > -1) {
|
||||||
String prototype = helmaKey.substring (0, dot);
|
String prototype = helmaKey.substring (0, dot);
|
||||||
INode node = (INode) nodeCache.get (prototype);
|
INode node = (INode) nodeCache.get (prototype);
|
||||||
if (node != null)
|
helmaKey = helmaKey.substring (dot+1);
|
||||||
node.setString (helmaKey.substring (dot+1), XmlUtil.getTextContent (childNode));
|
if (node != null && node.getString(helmaKey, false)==null)
|
||||||
}
|
node.setString (helmaKey, XmlUtil.getTextContent (childNode));
|
||||||
if ( helmaNode.getPrototype() != null && helmaNode.getString(helmaKey,false)==null ) {
|
} else if ( helmaNode.getString(helmaKey,false)==null ) {
|
||||||
helmaNode.setString( helmaKey, XmlUtil.getTextContent(childNode) );
|
helmaNode.setString( helmaKey, XmlUtil.getTextContent(childNode) );
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
debug("childtext-2-property mapping, setting " + helmaKey + " as string" );
|
debug("childtext-2-property mapping, setting " + helmaKey + " as string" );
|
||||||
|
@ -217,8 +217,13 @@ public class XmlConverter implements XmlConstants {
|
||||||
if ( helmaKey==null && !sparse ) {
|
if ( helmaKey==null && !sparse ) {
|
||||||
helmaKey = childElement.getNodeName().replace(':',defaultSeparator);
|
helmaKey = childElement.getNodeName().replace(':',defaultSeparator);
|
||||||
}
|
}
|
||||||
if (helmaKey == null)
|
if (helmaKey == null) {
|
||||||
|
// we don't map this child element itself since we do
|
||||||
|
// sparse parsing, but there may be something of interest
|
||||||
|
// in the child's child elements.
|
||||||
|
children (childElement, helmaNode, nodeCache);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// get the node on which to opererate, depending on the helmaKey
|
// get the node on which to opererate, depending on the helmaKey
|
||||||
// value from the properties file.
|
// value from the properties file.
|
||||||
|
@ -258,7 +263,7 @@ public class XmlConverter implements XmlConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there's some text content for this element, map it:
|
// if there's some text content for this element, map it:
|
||||||
if ( textcontent.length()>0 ) {
|
if ( textcontent.length()>0 && !sparse ) {
|
||||||
helmaKey = props.getProperty(element.getNodeName()+"._text");
|
helmaKey = props.getProperty(element.getNodeName()+"._text");
|
||||||
if ( helmaKey==null )
|
if ( helmaKey==null )
|
||||||
helmaKey = "text";
|
helmaKey = "text";
|
||||||
|
|
Loading…
Add table
Reference in a new issue