本文整理汇总了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");
}
}