本文整理汇总了Java中net.sf.saxon.lib.ParseOptions类的典型用法代码示例。如果您正苦于以下问题:Java ParseOptions类的具体用法?Java ParseOptions怎么用?Java ParseOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseOptions类属于net.sf.saxon.lib包,在下文中一共展示了ParseOptions类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import net.sf.saxon.lib.ParseOptions; //导入依赖的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.lib.ParseOptions; //导入依赖的package包/类
@Override
public ZeroOrOne<NodeInfo> call(XPathContext context, Sequence[] arguments) throws XPathException {
String xml = ((StringValue) arguments[0].head()).getStringValue();
try {
Controller controller = context.getController();
if (controller == null) {
throw new XPathException("parse() function is not available in this environment");
}
Configuration configuration = controller.getConfiguration();
StringReader sr = new StringReader(xml);
InputSource is = new InputSource(sr);
//is.setSystemId(baseURI);
Source source = new SAXSource(is);
//source.setSystemId(baseURI);
Builder b = TreeModel.TINY_TREE.makeBuilder(controller.makePipelineConfiguration());
Receiver s = b;
ParseOptions options = new ParseOptions();
options.setStripSpace(Whitespace.XSLT);
options.setErrorListener(context.getConfiguration().getErrorListener());
if (controller.getExecutable().stripsInputTypeAnnotations()) {
s = configuration.getAnnotationStripper(s);
}
s.setPipelineConfiguration(b.getPipelineConfiguration());
Sender.send(source, s, options);
TinyDocumentImpl node = (TinyDocumentImpl) b.getCurrentRoot();
// node.setBaseURI(baseURI);
node.setSystemId(null);
b.reset();
return new ZeroOrOne<NodeInfo>((NodeInfo)node);
} catch (XPathException err) {
throw new XPathException("First argument to parse is not a well-formed and namespace-well-formed XML document. XML parser reported: " + err.getMessage(), "FODC0006");
}
}
示例3: serializeToResult
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public <T extends Result> T serializeToResult(Source src, T result, Properties outProps) throws SaxonApiException {
CrigttConfiguration config = this.getProcessor().getUnderlyingConfiguration();
ParseOptions parseOpts = config.getParseOptions();
try {
Receiver receiver = config.getSerializerFactory().getReceiver(result, config.makePipelineConfiguration(), outProps);
if (src instanceof AugmentedSource) {
AugmentedSource augmentedSrc = ((AugmentedSource) src);
parseOpts = augmentedSrc.getParseOptions();
List<FilterFactory> srcFilters = augmentedSrc.getFilters();
if (!CollectionUtils.isEmpty(srcFilters)) {
for (int a = (srcFilters.size() - 1); a >= 0; a--) {
receiver = srcFilters.get(a).makeFilter(receiver);
}
srcFilters.clear();
}
}
Sender.send(src, receiver, parseOpts);
receiver.close();
} catch (XPathException e) {
throw new SaxonApiException(e);
}
return result;
}
示例4: makePipelineConfiguration
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
@Override
public CrigttPipelineConfiguration makePipelineConfiguration() {
CrigttPipelineConfiguration pipelineConfig = new CrigttPipelineConfiguration(this);
pipelineConfig.setErrorListener(this.getErrorListener());
pipelineConfig.setParseOptions(new ParseOptions(this.getParseOptions()));
pipelineConfig.setURIResolver(this.getURIResolver());
return pipelineConfig;
}
示例5: SdcctPipelineConfiguration
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public SdcctPipelineConfiguration(SdcctSaxonConfiguration config) {
super(config);
this.setParseOptions(new ParseOptions(config.getParseOptions()));
}
示例6: XmlDecodeOptionsImpl
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public XmlDecodeOptionsImpl(ParseOptions parseOpts) {
super(parseOpts);
}
示例7: AbstractXmlCodecOptions
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
protected AbstractXmlCodecOptions(ParseOptions parseOpts) {
super();
this.parseOpts = new ParseOptions(parseOpts);
}
示例8: getParseOptions
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
@Override
public ParseOptions getParseOptions() {
return this.parseOpts;
}
示例9: XmlEncodeOptionsImpl
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public XmlEncodeOptionsImpl(ParseOptions parseOpts) {
super(parseOpts);
}
示例10: serialize
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public byte[] serialize(Source src, @Nullable ParseOptions parseOpts, @Nullable Properties outProps) throws SaxonApiException {
return this.serialize(src, new ByteArrayResult(), parseOpts, outProps).getBytes();
}
示例11: getXMLStreamWriter
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public StreamWriterToReceiver getXMLStreamWriter(SdcctSaxonConfiguration config, SdcctPipelineConfiguration pipelineConfig, Result result,
@Nullable ParseOptions parseOpts, @Nullable Properties outProps) throws SaxonApiException {
return new StreamWriterToReceiver(this.getReceiver(config, pipelineConfig, result, parseOpts, outProps));
}
示例12: getParseOptions
import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public ParseOptions getParseOptions();