public static RevisionAwareXPath parseXPath(final StmtContext<?, ?, ?> ctx, final String path) {
final XPath xPath = XPATH_FACTORY.get().newXPath();
xPath.setNamespaceContext(StmtNamespaceContext.create(ctx,
ImmutableBiMap.of(RFC6020_YANG_NAMESPACE.toString(), YANG_XPATH_FUNCTIONS_PREFIX)));
final String trimmed = trimSingleLastSlashFromXPath(path);
try {
// XPath extension functions have to be prefixed
// yang-specific XPath functions are in fact extended functions, therefore we have to add
// "yang" prefix to them so that they can be properly validated with the XPath.compile() method
// the "yang" prefix is bound to RFC6020 YANG namespace
final String prefixedXPath = addPrefixToYangXPathFunctions(trimmed, ctx);
// TODO: we could capture the result and expose its 'evaluate' method
xPath.compile(prefixedXPath);
} catch (final XPathExpressionException e) {
LOG.warn("Argument \"{}\" is not valid XPath string at \"{}\"", path, ctx.getStatementSourceReference(), e);
}
return new RevisionAwareXPathImpl(path, PATH_ABS.matcher(path).matches());
}
ArgumentUtils.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:yangtools
作者:
评论列表
文章目录