Fix SchemaContextUtil.findDataSchemaNodeForRelativeXPath()
Description
Environment
duplicates
relates to
Activity

Robert Varga January 28, 2021 at 12:06 PM
This entire method needs to go. Its input context is woefully inadequate to actually perform the task. Also the implementation parses strings – for an input which already have as structured input!
So we actually need to add the following method to SchemaInferenceStack:
This will need to operate on both absolute and relative path, but that distinction is very simple (absolute == rewind to root and perform relative).
The implementation can follow PathExpression.getSteps() rather than getOriginalString() it currently takes.

Illia.Ihushev November 17, 2020 at 10:49 PMEdited
Gerrit change is a correctly working solution, but it is dirty. createWalkablePath, resolveRelativePath, findTargetNode should be refactored in order to get rid of such conditionals:
if (... == null)
{ return null; }
Possibly divide every method into two versions one for when the root node of a relativePath is a grouping and another one when not.
Details
Details
Assignee

Reporter

On resolving relative paths for key_leaf1 and leaf2 leafrefs(with findDataSchemaNodeForRelativeXPath) SchemaContextUtil.resolveRelativePath() returns incorrect paths.
module
Incorrect paths:
for key_leaf1: [(a)foo_grp, (a)key_leaf1, (a)foo_cont, (a)name]
for leaf2: [(a)bar_cont, (a)leaf2, (a)foo_cont, (a)name]
On call findDataSchemaNodeForRelativeXPath with leaf2 fails with
On call findDataSchemaNodeForRelativeXPath with key_leaf1 returns null.
Let's check whether the path goes behind grouping root node or root node of a different type. With this improvement, we will not lookup knowingly incorrect paths.