[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 |
||
| 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 |
| Comment by Igor Foltin [ 16/Jun/17 ] |
| Comment by Igor Foltin [ 21/Jun/17 ] |
|
Follow-up fix for the BGPCEP project: |
| 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. 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"> 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. |