Fix EXI fidelity parsing 35/35135/5
authorRobert Varga <robert.varga@pantheon.sk>
Sat, 20 Feb 2016 16:10:34 +0000 (17:10 +0100)
committerRobert Varga <robert.varga@pantheon.sk>
Mon, 22 Feb 2016 13:45:13 +0000 (14:45 +0100)
The fidelity elements are stored in a container, look them up in it.

Change-Id: I94c4f11ce469d9c1316a561facb9b269dc47d27a
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/exi/EXIParameters.java

index 35451ca04c91e60beb66d450d71b091ec235c5d9..8ba28731481cf0fc8dee499e6e876054871e0def 100644 (file)
@@ -12,10 +12,10 @@ import org.opendaylight.controller.config.util.xml.XmlElement;
 import org.openexi.proc.common.AlignmentType;
 import org.openexi.proc.common.EXIOptions;
 import org.openexi.proc.common.EXIOptionsException;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
 
 public final class EXIParameters {
     private static final String EXI_PARAMETER_ALIGNMENT = "alignment";
@@ -66,20 +66,22 @@ public final class EXIParameters {
             options.setAlignmentType(AlignmentType.bitPacked);
         }
 
-        if (root.getElementsByTagName(EXI_PARAMETER_FIDELITY).getLength() > 0) {
-            if (root.getElementsByTagName(EXI_FIDELITY_DTD).getLength() > 0) {
+        final NodeList fidelityElements = root.getElementsByTagName(EXI_PARAMETER_FIDELITY);
+        if (fidelityElements.getLength() > 0) {
+            final Element fidelityElement = (Element) fidelityElements.item(0);
+            if (fidelityElement.getElementsByTagName(EXI_FIDELITY_DTD).getLength() > 0) {
                 options.setPreserveDTD(true);
             }
-            if (root.getElementsByTagName(EXI_FIDELITY_LEXICAL_VALUES).getLength() > 0) {
+            if (fidelityElement.getElementsByTagName(EXI_FIDELITY_LEXICAL_VALUES).getLength() > 0) {
                 options.setPreserveLexicalValues(true);
             }
-            if (root.getElementsByTagName(EXI_FIDELITY_COMMENTS).getLength() > 0) {
+            if (fidelityElement.getElementsByTagName(EXI_FIDELITY_COMMENTS).getLength() > 0) {
                 options.setPreserveComments(true);
             }
-            if (root.getElementsByTagName(EXI_FIDELITY_PIS).getLength() > 0) {
+            if (fidelityElement.getElementsByTagName(EXI_FIDELITY_PIS).getLength() > 0) {
                 options.setPreservePIs(true);
             }
-            if (root.getElementsByTagName(EXI_FIDELITY_PREFIXES).getLength() > 0) {
+            if (fidelityElement.getElementsByTagName(EXI_FIDELITY_PREFIXES).getLength() > 0) {
                 options.setPreserveNS(true);
             }
         }