当前位置: 首页>>代码示例>>Java>>正文


Java XPathContext.getContextItem方法代码示例

本文整理汇总了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);
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:15,代码来源:ResolveEmbeddedXPathCall.java

示例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());
		}
	}
}
 
开发者ID:dita-semia,项目名称:dita-semia-resolver,代码行数:34,代码来源:GetKeyDefLocationCall.java

示例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;
}
 
开发者ID:dita-semia,项目名称:XsltGui,代码行数:10,代码来源:GuiOpenFile.java

示例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;
    	}
    }
 
开发者ID:dita-semia,项目名称:XsltGui,代码行数:16,代码来源:GuiHtmlDialog.java


注:本文中的net.sf.saxon.expr.XPathContext.getContextItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。