本文整理汇总了Java中net.sf.saxon.expr.XPathContext.getContextItem方法的典型用法代码示例。如果您正苦于以下问题:Java XPathContext.getContextItem方法的具体用法?Java XPathContext.getContextItem怎么用?Java XPathContext.getContextItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.expr.XPathContext
的用法示例。
在下文中一共展示了XPathContext.getContextItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
final Item contextItem = context.getContextItem();
if (!(contextItem instanceof NodeInfo)) {
throw new XPathException("Context item '" + contextItem.getClass() + "'needs to be an instance of NodeInfo.");
}
final String xPath = arguments[0].head().getStringValue();
final SaxonNodeWrapper contextNode = new SaxonNodeWrapper((NodeInfo)contextItem, otResolver.getXPathCache());
final String resolvedXPath = EmbeddedXPathResolver.resolve(xPath, contextNode);
return new StringValue(resolvedXPath);
}
示例2: call
import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
final Item contextItem = context.getContextItem();
if (!(contextItem instanceof NodeInfo)) {
throw new XPathException("Context item '" + contextItem.getClass() + "' needs to be an instance of NodeInfo.");
}
final NodeInfo contextNode = (NodeInfo)contextItem;
final KeyDefInterface keyDef = DitaSemiaOtResolver.getKeyDefFromItem(arguments[0].head());
final URL defUrl = keyDef.getDefUrl();
final String defId = keyDef.getDefId();
if ((defUrl == null) || (defId == null)) {
return EmptySequence.getInstance();
} else {
try {
final URI baseUri = new URI(contextNode.getBaseURI());
final URI relativeUri = baseUri.relativize(defUrl.toURI());
final StringBuffer location = new StringBuffer();
location.append(relativeUri.getPath());
location.append(DitaUtil.HREF_URL_ID_DELIMITER);
final String defAncestorTopicId = keyDef.getDefAncestorTopicId();
if (defAncestorTopicId != null) {
location.append(defAncestorTopicId);
location.append(DitaUtil.HREF_TOPIC_ID_DELIMITER);
}
location.append(defId);
return new StringValue(location.toString());
} catch (URISyntaxException e) {
throw new XPathException(e.getMessage());
}
}
}
示例3: getURL
import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
private URL getURL(XPathContext context, String filename) throws MalformedURLException {
URL base = null;
final Item item = context.getContextItem();
if (item instanceof NodeInfo) {
base = new URL(((NodeInfo) item).getBaseURI());
}
URL url = new URL(base, filename);
return url;
}
示例4: getCssUrl
import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
private URL getCssUrl(XPathContext context, Sequence[] arguments) throws MalformedURLException, XPathException {
//logger.info("getCssUrl()");
String cssUri = arguments[CSS_URI].head().getStringValue();
if (cssUri.isEmpty()) {
return null;
} else {
URL base = null;
final Item item = context.getContextItem();
if (item instanceof NodeInfo) {
base = new URL(((NodeInfo) item).getBaseURI());
}
URL url = new URL(base, cssUri);
return url;
}
}