Fix missing location in error reports
[yangtools.git] / yang / yang-data-codec-xml / src / main / java / org / opendaylight / yangtools / yang / data / codec / xml / XmlParserStream.java
index c97b6575653709ce1b87b8d3d23d4b03659dadca..5c3d7e3735b2fb0b64c919fb094d6855c002f20f 100644 (file)
@@ -74,6 +74,7 @@ import org.opendaylight.yangtools.yang.data.util.SimpleNodeDataWithSchema;
 import org.opendaylight.yangtools.yang.data.util.YangModeledAnyXmlNodeDataWithSchema;
 import org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AnyxmlSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ContainerLike;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
@@ -251,8 +252,8 @@ public final class XmlParserStream implements Closeable, Flushable {
         if (reader.hasNext()) {
             reader.nextTag();
             final AbstractNodeDataWithSchema<?> nodeDataWithSchema;
-            if (parentNode instanceof ContainerSchemaNode) {
-                nodeDataWithSchema = new ContainerNodeDataWithSchema((ContainerSchemaNode) parentNode);
+            if (parentNode instanceof ContainerLike) {
+                nodeDataWithSchema = new ContainerNodeDataWithSchema((ContainerLike) parentNode);
             } else if (parentNode instanceof ListSchemaNode) {
                 nodeDataWithSchema = new ListNodeDataWithSchema((ListSchemaNode) parentNode);
             } else if (parentNode instanceof YangModeledAnyxmlSchemaNode) {
@@ -438,7 +439,7 @@ public final class XmlParserStream implements Closeable, Flushable {
 
         switch (in.nextTag()) {
             case XMLStreamConstants.START_ELEMENT:
-                // FIXME: 6.0.0: why do we even need this tracker? either document it or remove it.
+                // FIXME: 7.0.0: why do we even need this tracker? either document it or remove it.
                 //               it looks like it is a crude duplicate finder, which should really be handled via
                 //               ChildReusePolicy.REJECT
                 final Set<Entry<String, String>> namesakes = new HashSet<>();
@@ -486,7 +487,7 @@ public final class XmlParserStream implements Closeable, Flushable {
                         if (!added && !elementList) {
                             throw new XMLStreamException(String.format(
                                 "Duplicate element \"%s\" in namespace \"%s\" with parent \"%s\" in XML input",
-                                xmlElementName, elementNS, parent.getSchema()), in.getLocation());
+                                xmlElementName, elementNS, parentSchema), in.getLocation());
                         }
 
                         // We have a match, proceed with it
@@ -503,7 +504,8 @@ public final class XmlParserStream implements Closeable, Flushable {
                         } else if (parentSchema instanceof ListSchemaNode) {
                             optMount = MountPointSchemaNode.streamAll((ListSchemaNode) parentSchema).findFirst();
                         } else {
-                            throw new XMLStreamException("Unhandled mount-aware schema " + parentSchema);
+                            throw new XMLStreamException("Unhandled mount-aware schema " + parentSchema,
+                                in.getLocation());
                         }
 
                         if (optMount.isPresent()) {
@@ -529,7 +531,7 @@ public final class XmlParserStream implements Closeable, Flushable {
                     if (strictParsing) {
                         throw new XMLStreamException(String.format(
                             "Schema for node with name %s and namespace %s does not exist at %s", xmlElementName,
-                            elementNS, parentSchema.getPath(), in.getLocation()));
+                            elementNS, parentSchema.getPath()), in.getLocation());
                     }
 
                     LOG.debug("Skipping unknown node ns=\"{}\" localName=\"{}\" at path {}", elementNS, xmlElementName,