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


Java ParseOptions类代码示例

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

示例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");
  }

}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:39,代码来源:Parse.java

示例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;
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:33,代码来源:CrigttSerializer.java

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

示例5: SdcctPipelineConfiguration

import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public SdcctPipelineConfiguration(SdcctSaxonConfiguration config) {
    super(config);

    this.setParseOptions(new ParseOptions(config.getParseOptions()));
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:6,代码来源:SdcctPipelineConfiguration.java

示例6: XmlDecodeOptionsImpl

import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public XmlDecodeOptionsImpl(ParseOptions parseOpts) {
    super(parseOpts);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:4,代码来源:XmlDecodeOptionsImpl.java

示例7: AbstractXmlCodecOptions

import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
protected AbstractXmlCodecOptions(ParseOptions parseOpts) {
    super();

    this.parseOpts = new ParseOptions(parseOpts);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:6,代码来源:AbstractXmlCodecOptions.java

示例8: getParseOptions

import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
@Override
public ParseOptions getParseOptions() {
    return this.parseOpts;
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:5,代码来源:AbstractXmlCodecOptions.java

示例9: XmlEncodeOptionsImpl

import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public XmlEncodeOptionsImpl(ParseOptions parseOpts) {
    super(parseOpts);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:4,代码来源:XmlEncodeOptionsImpl.java

示例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();
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:4,代码来源:SdcctSerializer.java

示例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));
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:5,代码来源:SdcctSerializer.java

示例12: getParseOptions

import net.sf.saxon.lib.ParseOptions; //导入依赖的package包/类
public ParseOptions getParseOptions(); 
开发者ID:esacinc,项目名称:sdcct,代码行数:2,代码来源:XmlCodecOptions.java


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