當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。