本文整理汇总了Java中net.sf.saxon.expr.XPathContext.getConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java XPathContext.getConfiguration方法的具体用法?Java XPathContext.getConfiguration怎么用?Java XPathContext.getConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.saxon.expr.XPathContext
的用法示例。
在下文中一共展示了XPathContext.getConfiguration方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
try {
String json = ((StringValue) arguments[0].head()).getStringValue();
if (StringUtils.isBlank(json)) {
return EmptySequence.getInstance();
}
XMLInputFactory factory = new JsonXMLInputFactory();
XMLStreamReader reader = factory.createXMLStreamReader(new StringReader(json));
StAXSource source = new StAXSource(reader);
Configuration config = context.getConfiguration();
PipelineConfiguration pipe = config.makePipelineConfiguration();
pipe.getParseOptions().getParserFeatures().remove("http://apache.org/xml/features/xinclude");
TinyBuilder builder = new TinyBuilder(pipe);
SerializerFactory sf = config.getSerializerFactory();
Receiver receiver = sf.getReceiver(builder, pipe, new Properties());
NamespaceReducer reducer = new NamespaceReducer(receiver);
ParseOptions options = pipe.getParseOptions();
options.setContinueAfterValidationErrors(true);
Sender.send(source, reducer, options);
return builder.getCurrentRoot();
} catch (Exception e) {
throw new XPathException("Error parsing JSON string", e);
}
}
示例2: call
import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
final Processor processor = new Processor(context.getConfiguration());
final DocumentBuilder builder = processor.newDocumentBuilder();
try {
BuildingStreamWriterImpl writer = builder.newBuildingStreamWriter();
writer.writeStartElement("test1");
writer.writeCharacters("text1");
writer.writeEndElement();
writer.writeStartElement("test2");
writer.writeCharacters("text2");
writer.writeEndElement();
return writer.getDocumentNode().getUnderlyingValue();
} catch (SaxonApiException | XMLStreamException e) {
logger.error(e, e);
throw new XPathException("Failed to create return value: " + e.getMessage());
}
}
示例3: createKeyTypeElement
import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
private Sequence createKeyTypeElement(XPathContext context, String keyTypeName) throws XPathException {
final KeyTypeDef keyTypeDef = otResolver.getBookCache().getKeyTypeDef(keyTypeName);
final Processor processor = new Processor(context.getConfiguration());
final DocumentBuilder builder = processor.newDocumentBuilder();
try {
BuildingStreamWriterImpl writer = builder.newBuildingStreamWriter();
writer.writeStartElement(KeyTypeDef.ELEMENT);
writer.writeAttribute(KeyTypeDef.ATTR_NAME, keyTypeDef.getName());
writer.writeAttribute(KeyTypeDef.ATTR_IS_CODE_FONT, Boolean.toString(keyTypeDef.isCodeFont()));
writer.writeAttribute(KeyTypeDef.ATTR_IS_ITALIC_FONT, Boolean.toString(keyTypeDef.isItalicFont()));
writer.writeAttribute(KeyTypeDef.ATTR_PREFIX, keyTypeDef.getPrefix());
writer.writeAttribute(KeyTypeDef.ATTR_SUFFIX, keyTypeDef.getSuffix());
writer.writeAttribute(KeyTypeDef.ATTR_SELECT_PRIORITY, Integer.toString(keyTypeDef.getSelectPriority()));
writer.writeEndElement();
final XdmSequenceIterator iterator = writer.getDocumentNode().axisIterator(Axis.CHILD);
return iterator.next().getUnderlyingValue();
} catch (SaxonApiException | XMLStreamException e) {
logger.error(e, e);
throw new XPathException("Failed to create element: " + e.getMessage());
}
}
示例4: call
import net.sf.saxon.expr.XPathContext; //导入方法依赖的package包/类
@Override
public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {
final Item keyDefItem = arguments[0].head();
if (keyDefItem != null) {
final KeyDefInterface keyDef = DitaSemiaOtResolver.getKeyDefFromItem(keyDefItem);
//logger.info(keyDef + ": " + keyDef.isFilteredKey());
final FilterAttrSet set = keyDef.getKeyFilterAttrSet();
final Map<String, Set<String>> map = (set == null) ? null : set.getMap();
if (map != null) {
final Processor processor = new Processor(context.getConfiguration());
final DocumentBuilder builder = processor.newDocumentBuilder();
try {
BuildingStreamWriterImpl writer = builder.newBuildingStreamWriter();
writer.writeStartElement("Container");
for (Entry<String, Set<String>> entry : map.entrySet()) {
writer.writeAttribute(entry.getKey(), String.join(" ", entry.getValue()));
}
writer.writeEndElement();
XdmSequenceIterator iterator = writer.getDocumentNode().axisIterator(Axis.CHILD);
return ((XdmNode)iterator.next()).getUnderlyingNode();
} catch (SaxonApiException | XMLStreamException e) {
throw new XPathException("Failed to create result-node", e);
}
}
}
return EmptySequence.getInstance();
}