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


Java Builder类代码示例

本文整理汇总了Java中net.sf.saxon.event.Builder的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: call

import net.sf.saxon.event.Builder; //导入依赖的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


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