BUG-472 Initial EXI encoder/decoder implementation in Netconf
[controller.git] / opendaylight / netconf / netconf-util / src / main / java / org / opendaylight / controller / netconf / util / xml / EXIParameters.java
index 2c8a16cbe1db93b57cef255bdec5e0eb774eb7d2..593b77f193e8cd38aca8ca5fbea5b9606bd11c9e 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.netconf.util.xml;
 
+import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.openexi.proc.common.AlignmentType;
 import org.openexi.proc.common.EXIOptions;
 import org.openexi.proc.common.EXIOptionsException;
@@ -38,7 +39,11 @@ public final class EXIParameters {
         this.options = Preconditions.checkNotNull(options);
     }
 
-    public static EXIParameters forXmlElement(final XmlElement root) throws EXIOptionsException {
+    public static EXIParameters fromNetconfMessage(final NetconfMessage root) throws EXIOptionsException {
+        return fromXmlElement(XmlElement.fromDomDocument(root.getDocument()));
+    }
+
+    public static EXIParameters fromXmlElement(final XmlElement root) throws EXIOptionsException {
         final EXIOptions options =  new EXIOptions();
 
         options.setAlignmentType(AlignmentType.bitPacked);
@@ -73,24 +78,25 @@ public final class EXIParameters {
         }
 
         if (root.getElementsByTagName(EXI_PARAMETER_SCHEMA).getLength() > 0) {
+/*
+                        GrammarFactory grammarFactory = GrammarFactory.newInstance();
+                        if (operationElement
+                                .getElementsByTagName(EXI_PARAMETER_SCHEMA_NONE)
+                                .getLength() > 0) {
+                            this.grammars = grammarFactory.createSchemaLessGrammars();
+                        }
+
+                        if (operationElement.getElementsByTagName(
+                                EXI_PARAMETER_SCHEMA_BUILT_IN).getLength() > 0) {
+                            this.grammars = grammarFactory.createXSDTypesOnlyGrammars();
+                        }
 
-            //            GrammarFactory grammarFactory = GrammarFactory.newInstance();
-            //            if (operationElement
-            //                    .getElementsByTagName(EXI_PARAMETER_SCHEMA_NONE)
-            //                    .getLength() > 0) {
-            //                this.grammars = grammarFactory.createSchemaLessGrammars();
-            //            }
-            //
-            //            if (operationElement.getElementsByTagName(
-            //                    EXI_PARAMETER_SCHEMA_BUILT_IN).getLength() > 0) {
-            //                this.grammars = grammarFactory.createXSDTypesOnlyGrammars();
-            //            }
-            //
-            //            if (operationElement.getElementsByTagName(
-            //                    EXI_PARAMETER_SCHEMA_BASE_1_1).getLength() > 0) {
-            //                this.grammars = grammarFactory
-            //                        .createGrammars(NETCONF_XSD_LOCATION);
-            //            }
+                        if (operationElement.getElementsByTagName(
+                                EXI_PARAMETER_SCHEMA_BASE_1_1).getLength() > 0) {
+                            this.grammars = grammarFactory
+                                    .createGrammars(NETCONF_XSD_LOCATION);
+                        }
+*/
 
         }