When we have split the path into its components, we can end up
compressing them further. Make sure the list is actually mutable.
JIRA: YANGTOOLS-1125
Change-Id: I1d4cd66d2efbb1955bb189763ea09fefeba93d25
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
69cb7d1ab7a329e2bd19f538b3d598be91c49f2d)
assertNull(SchemaContextUtil.findDataSchemaNodeForRelativeXPath(context, module, leaf,
((LeafrefTypeDefinition) leaf.getType()).getPathStatement()));
}
+
+ @Test
+ public void testNonExistentRelativeXpath() {
+ final LeafSchemaNode leaf = (LeafSchemaNode) bar.findDataChildByName(
+ QName.create(FOO, "indirect-with-current")).get();
+ assertNull(SchemaContextUtil.findDataSchemaNodeForRelativeXPath(context, module, leaf,
+ ((LeafrefTypeDefinition) leaf.getType()).getPathStatement()));
+ }
}
}
}
+ leaf indirect-with-current {
+ type leafref {
+ path "../../../n[n-id=current()/../node]/tp/tp-id";
+ }
+ }
+
leaf absolute {
type leafref {
// direct path to an instantiation
}
private static List<String> doSplitXPath(final String xpath) {
- return SLASH_SPLITTER.splitToList(xpath);
+ final List<String> ret = new ArrayList<>();
+ for (String str : SLASH_SPLITTER.split(xpath)) {
+ ret.add(str);
+ }
+ return ret;
}
/**