If we are passed a relative path, we end up first stripping it
and then realizing it's relative. Invert the order, making absolute
proper invariant.
Change-Id: Ic272ac83a9df9d2343b1cd8c5f71debdcdc0faad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
0236f96b973675555087801c0d786d7f19eee8f1)
public static TypeDefinition<?> getBaseTypeForLeafRef(final LeafrefTypeDefinition typeDefinition,
final SchemaContext schemaContext, final QName qname) {
final PathExpression pathStatement = typeDefinition.getPathStatement();
public static TypeDefinition<?> getBaseTypeForLeafRef(final LeafrefTypeDefinition typeDefinition,
final SchemaContext schemaContext, final QName qname) {
final PathExpression pathStatement = typeDefinition.getPathStatement();
- final PathExpression strippedPathStatement = new PathExpressionImpl(
- stripConditionsFromXPathString(pathStatement), pathStatement.isAbsolute());
- if (!strippedPathStatement.isAbsolute()) {
+ if (!pathStatement.isAbsolute()) {
+ final PathExpression strippedPathStatement = new PathExpressionImpl(
+ stripConditionsFromXPathString(pathStatement), true);
+
final Optional<Module> parentModule = schemaContext.findModule(qname.getModule());
checkArgument(parentModule.isPresent(), "Failed to find parent module for %s", qname);
final Optional<Module> parentModule = schemaContext.findModule(qname.getModule());
checkArgument(parentModule.isPresent(), "Failed to find parent module for %s", qname);