[YANGTOOLS-787] New XML parser design flaw Created: 13/Jun/17  Updated: 10/Apr/22  Resolved: 24/Jul/17

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Igor Foltin Assignee: Igor Foltin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 8675

 Description   

New XML parser (residing in yang-data-codec-xml) assumes that yang-modeled data in the parsed XML source are wrapped in a yang-independent root element which is not correct. Actually, the root element of such XML document should represent a specific yang data node defined in the provided yang model.



 Comments   
Comment by Igor Foltin [ 16/Jun/17 ]

Another issue with the XML parser is the SchemaNode parameter that is used when
creating an XmlParserStream instance. Currently, it represents a schema
node that is the parent node of the root XML element. However, this
parameter should correspond to the root XML element itself.

Comment by Igor Foltin [ 16/Jun/17 ]

Fix: https://git.opendaylight.org/gerrit/#/c/59036/

Comment by Igor Foltin [ 21/Jun/17 ]

Follow-up fix for the BGPCEP project:
https://git.opendaylight.org/gerrit/#/c/59268/

Comment by Igor Foltin [ 12/Jul/17 ]

Actually, ignore the first two comments.

It is irrelevant if the root XML element corresponds to the SchemaNode parentNode parameter or not. The SchemaNode parameter represents the parent SchemaNode of the YANG-modeled data that are wrapped inside the root XML element.

The actual flaw is that the parser wraps the parentNode parameter inside a CompositeNodeDataWithSchema which emits only its child nodes into the provided NormalizedNodeStreamWriter. The parentNode itself is not emitted which is a problem.

Here is an example which illustrates the issue.
Let's say we have a YANG module which looks like this:

module foo {

...

container foo-cont { list foo-list

{...}

}

...

}

We want to parse the foo-cont node, so we provide a corresponding foo-cont ContainerSchemaNode as the parentNode parameter to the XmlParserStream.

Now, imagine we have an XML source which looks like this:

<foo-cont xmlns="foo">
<foo-list> ...some other nodes... </foo-list>
</foo-cont>

If we parse this XML into a NormalizedNode tree, we will end up with a root NormalizedNode which corresponds to the foo-list node. However, it should be the foo-cont node.

Therefore we need to check the parentNode type and put it into a corresponding ...NodeDataWithSchema.
In the example above, it would be a ContainerNodeDataWithSchema.

Generated at Wed Feb 07 20:54:18 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.