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