本文整理汇总了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());
}
}
示例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());
}
}