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


Java Processor.setConfigurationProperty方法代码示例

本文整理汇总了Java中net.sf.saxon.s9api.Processor.setConfigurationProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Processor.setConfigurationProperty方法的具体用法?Java Processor.setConfigurationProperty怎么用?Java Processor.setConfigurationProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.saxon.s9api.Processor的用法示例。


在下文中一共展示了Processor.setConfigurationProperty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import net.sf.saxon.s9api.Processor; //导入方法依赖的package包/类
/**
 * Initialization to improve performance for repetitive invocations of filter and evaluate expressions
 * 
 * @throws XPathException
 */
private void init() throws XPathException {
	
	try {
		
		// Get the processor
		proc = new Processor(false);

		// Set any specified configuration properties for the processor
		if (featureMappings != null) {
			for (Entry<String, Object> entry : featureMappings.entrySet()) {
				proc.setConfigurationProperty(entry.getKey(), entry.getValue());
			}
		}
		
		//proc.setConfigurationProperty(FeatureKeys.ENTITY_RESOLVER_CLASS, "com.elsevier.spark_xml_utils.common.IgnoreDoctype");
		
		// Get the XPath compiler
		XPathCompiler xpathCompiler = proc.newXPathCompiler();

		// Set the namespace to prefix mappings
		this.setPrefixNamespaceMappings(xpathCompiler, namespaceMappings);

		// Compile the XPath expression  and get a document builder
		xsel = xpathCompiler.compile(xPathExpression).load();
		builder = proc.newDocumentBuilder();
	
		// Create and initialize the serializer  
		baos = new ByteArrayOutputStream();
		serializer = proc.newSerializer(baos);
		serializer.setOutputStream(baos);
		serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
		serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION,"yes");			
		serializer.setProcessor(proc);
	
	} catch (SaxonApiException e) {
		
		log.error("Problems creating an XPathProcessor.  " + e.getMessage(),e);
		throw new XPathException(e.getMessage());

	}
	
}
 
开发者ID:elsevierlabs-os,项目名称:spark-xml-utils,代码行数:48,代码来源:XPathProcessor.java

示例2: init

import net.sf.saxon.s9api.Processor; //导入方法依赖的package包/类
/**
 * Initialization to improve performance for repetitive invocations of evaluate expressions
 * 
 * @throws XQueryException
 */
private void init() throws XQueryException {
	
	try {
		
		// Get the processor
		proc = new Processor(false);

		// Set any specified configuration properties for the processor
		if (featureMappings != null) {
			for (Entry<String, Object> entry : featureMappings.entrySet()) {
				proc.setConfigurationProperty(entry.getKey(), entry.getValue());
			}
		}
		
		// Get the XQuery compiler
		XQueryCompiler xqueryCompiler = proc.newXQueryCompiler();
		xqueryCompiler.setEncoding(CharEncoding.UTF_8);

		// Set the namespace to prefix mappings
		this.setPrefixNamespaceMappings(xqueryCompiler, namespaceMappings);

		// Compile the XQuery expression and get an XQuery evaluator
		exp = xqueryCompiler.compile(xQueryExpression);
		eval = exp.load();
		
		// Create and initialize the serializer 
		baos = new ByteArrayOutputStream();
		serializer = proc.newSerializer(baos);
		// Appears ok to always set output property to xml (even if we are just returning a text string)
		serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
		serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION,"yes");
		serializer.setProcessor(proc);
		
	} catch (SaxonApiException e) {
		
		log.error("Problems creating an XQueryProcessor.  " + e.getMessage(),e);
		throw new XQueryException(e.getMessage());

	}
	
}
 
开发者ID:elsevierlabs-os,项目名称:spark-xml-utils,代码行数:47,代码来源:XQueryProcessor.java


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