本文整理了Java中net.sf.saxon.xpath.XPathFactoryImpl
类的一些代码示例,展示了XPathFactoryImpl
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XPathFactoryImpl
类的具体详情如下:
包路径:net.sf.saxon.xpath.XPathFactoryImpl
类名称:XPathFactoryImpl
[英]Saxon implementation of the JAXP 1.3 XPathFactory
[中]JAXP 1.3 XPathFactory的Saxon实现
代码示例来源:origin: mulesoft/mule
@Before
public void before() throws Exception {
XPathFactory xpathFactory = new XPathFactoryImpl();
xpath = xpathFactory.newXPath();
builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
}
代码示例来源:origin: org.opengis.cite.saxon/saxon9
/**
* Default constructor: this creates a Configuration as well as creating the XPathFactory. Any documents
* accessed using this XPathFactory must be built using this same Configuration.
*/
public XPathFactoryImpl() {
config = makeConfiguration();
}
代码示例来源:origin: in.jlibs/jlibs-examples
@Override
public List<Object> evaluate(TestCase testCase, String file) throws Exception{
XPathFactoryImpl xpf = new XPathFactoryImpl();
XPathEvaluator xpe = (XPathEvaluator)xpf.newXPath();
xpe.getConfiguration().setVersionWarning(false);
((StandardErrorListener)xpe.getConfiguration().getErrorListener()).setRecoveryPolicy(Configuration.RECOVER_SILENTLY);
xpe.getStaticContext().setBackwardsCompatibilityMode(true);
xpe.setXPathVariableResolver(testCase.variableResolver);
xpe.setXPathFunctionResolver(testCase.functionResolver);
xpe.setNamespaceContext(testCase.nsContext);
NodeInfo doc = xpe.getConfiguration().buildDocument(new SAXSource(new InputSource(file)));
List<Object> results = new ArrayList<Object>(testCase.xpaths.size());
for(XPathInfo xpathInfo: testCase.xpaths){
if(xpathInfo.forEach==null)
results.add(xpe.evaluate(xpathInfo.xpath, doc, xpathInfo.resultType));
else{
List<Object> list = new ArrayList<Object>();
List nodeList = (List)xpe.evaluate(xpathInfo.forEach, doc, XPathConstants.NODESET);
for(Object context: nodeList)
list.add(xpe.evaluate(xpathInfo.xpath, context, xpathInfo.resultType));
results.add(list);
}
}
return results;
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Default constructor: this creates a Configuration as well as creating the XPathFactory. Any documents
* accessed using this XPathFactory must be built using this same Configuration.
*/
public XPathFactoryImpl() {
config = Configuration.newConfiguration();
setConfiguration(config);
Version.platform.registerAllBuiltInObjectModels(config);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Test whether a given object model is supported. Returns true if the object model
* is the Saxon object model, DOM, JDOM, DOM4J, or XOM
*
* @param model The URI identifying the object model.
* @return true if the object model is one of the following (provided that the supporting
* JAR file is available on the classpath)
* {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_SAXON},
* {@link XPathConstants#DOM_OBJECT_MODEL},
* {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_JDOM}, or
* {@link NamespaceConstant#OBJECT_MODEL_XOM}, or
* {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_DOM4J}.
* Saxon also allows user-defined external object models to be registered with the Configuration, and
* this method will return true in respect of any such model.
*/
public boolean isObjectModelSupported(String model) {
boolean debug = System.getProperty("jaxp.debug") != null;
boolean result = silentIsObjectModelSupported(model);
if (debug) {
System.err.println("JAXP: Calling " + getClass().getName() + ".isObjectModelSupported(\"" + model + "\")");
System.err.println("JAXP: -- returning " + (result ? "true" : "false (check all required libraries are on the class path"));
}
return result;
}
代码示例来源:origin: org.jboss.soa.bpel/riftsaw-bpel-runtime
JaxpVariableResolver varResolver = new JaxpVariableResolver(ctx, oxpath20, ((XPathFactoryImpl) _xpf).getConfiguration());
XPath xpe = _xpf.newXPath();
xpe.setXPathFunctionResolver(funcResolver);
XPath20ExpressionModifier modifier = new XPath20ExpressionModifier(oxpath20.namespaceCtx, ((XPathFactoryImpl) _xpf).getConfiguration().getNamePool());
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon
/**
* Default constructor: this creates a Configuration as well as creating the XPathFactory. Any documents
* accessed using this XPathFactory must be built using this same Configuration.
*/
public XPathFactoryImpl() {
config = Configuration.newConfiguration();
setConfiguration(config);
Version.platform.registerAllBuiltInObjectModels(config);
}
代码示例来源:origin: net.sf.saxon/Saxon-HE
/**
* Test whether a given object model is supported. Returns true if the object model
* is the Saxon object model, DOM, JDOM, DOM4J, or XOM
*
* @param model The URI identifying the object model.
* @return true if the object model is one of the following (provided that the supporting
* JAR file is available on the classpath)
* {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_SAXON},
* {@link XPathConstants#DOM_OBJECT_MODEL},
* {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_JDOM}, or
* {@link NamespaceConstant#OBJECT_MODEL_XOM}, or
* {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_DOM4J}.
* Saxon also allows user-defined external object models to be registered with the Configuration, and
* this method will return true in respect of any such model.
*/
public boolean isObjectModelSupported(String model) {
boolean debug = System.getProperty("jaxp.debug") != null;
boolean result = silentIsObjectModelSupported(model);
if (debug) {
System.err.println("JAXP: Calling " + getClass().getName() + ".isObjectModelSupported(\"" + model + "\")");
System.err.println("JAXP: -- returning " + (result ? "true" : "false (check all required libraries are on the class path"));
}
return result;
}
代码示例来源:origin: org.mule.modules/mule-module-xml
/**
* {@inheritDoc}
* Returns instances of {@link XPathFactoryImpl}
*/
@Override
protected XPathFactory createXPathFactory()
{
return new XPathFactoryImpl();
}
}
代码示例来源:origin: goldmansachs/jdmn
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: goldmansachs/jdmn
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: goldmansachs/jdmn
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: goldmansachs/jdmn
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: goldmansachs/jdmn
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
// Read document
String xml = "<root>" + input + "</root>";
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Document document = docBuilder.parse(inputStream);
// Evaluate xpath
XPathFactory xPathFactory = new XPathFactoryImpl();
XPath xPath = xPathFactory.newXPath();
return xPath.evaluate(expression, document.getDocumentElement());
}
代码示例来源:origin: org.mule.runtime/mule-module-extensions-spring-support
@Before
public void before() throws Exception {
XPathFactory xpathFactory = new XPathFactoryImpl();
xpath = xpathFactory.newXPath();
builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
}
内容来源于网络,如有侵权,请联系作者删除!