net.sf.saxon.xpath.XPathFactoryImpl类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(12.7k)|赞(0)|评价(0)|浏览(73)

本文整理了Java中net.sf.saxon.xpath.XPathFactoryImpl类的一些代码示例,展示了XPathFactoryImpl类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XPathFactoryImpl类的具体详情如下:
包路径:net.sf.saxon.xpath.XPathFactoryImpl
类名称:XPathFactoryImpl

XPathFactoryImpl介绍

[英]Saxon implementation of the JAXP 1.3 XPathFactory
[中]JAXP 1.3 XPathFactory的Saxon实现

代码示例

代码示例来源:origin: mulesoft/mule

  1. @Before
  2. public void before() throws Exception {
  3. XPathFactory xpathFactory = new XPathFactoryImpl();
  4. xpath = xpathFactory.newXPath();
  5. builderFactory = DocumentBuilderFactory.newInstance();
  6. builderFactory.setNamespaceAware(true);
  7. }

代码示例来源:origin: org.opengis.cite.saxon/saxon9

  1. /**
  2. * Default constructor: this creates a Configuration as well as creating the XPathFactory. Any documents
  3. * accessed using this XPathFactory must be built using this same Configuration.
  4. */
  5. public XPathFactoryImpl() {
  6. config = makeConfiguration();
  7. }

代码示例来源:origin: in.jlibs/jlibs-examples

  1. @Override
  2. public List<Object> evaluate(TestCase testCase, String file) throws Exception{
  3. XPathFactoryImpl xpf = new XPathFactoryImpl();
  4. XPathEvaluator xpe = (XPathEvaluator)xpf.newXPath();
  5. xpe.getConfiguration().setVersionWarning(false);
  6. ((StandardErrorListener)xpe.getConfiguration().getErrorListener()).setRecoveryPolicy(Configuration.RECOVER_SILENTLY);
  7. xpe.getStaticContext().setBackwardsCompatibilityMode(true);
  8. xpe.setXPathVariableResolver(testCase.variableResolver);
  9. xpe.setXPathFunctionResolver(testCase.functionResolver);
  10. xpe.setNamespaceContext(testCase.nsContext);
  11. NodeInfo doc = xpe.getConfiguration().buildDocument(new SAXSource(new InputSource(file)));
  12. List<Object> results = new ArrayList<Object>(testCase.xpaths.size());
  13. for(XPathInfo xpathInfo: testCase.xpaths){
  14. if(xpathInfo.forEach==null)
  15. results.add(xpe.evaluate(xpathInfo.xpath, doc, xpathInfo.resultType));
  16. else{
  17. List<Object> list = new ArrayList<Object>();
  18. List nodeList = (List)xpe.evaluate(xpathInfo.forEach, doc, XPathConstants.NODESET);
  19. for(Object context: nodeList)
  20. list.add(xpe.evaluate(xpathInfo.xpath, context, xpathInfo.resultType));
  21. results.add(list);
  22. }
  23. }
  24. return results;
  25. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Default constructor: this creates a Configuration as well as creating the XPathFactory. Any documents
  3. * accessed using this XPathFactory must be built using this same Configuration.
  4. */
  5. public XPathFactoryImpl() {
  6. config = Configuration.newConfiguration();
  7. setConfiguration(config);
  8. Version.platform.registerAllBuiltInObjectModels(config);
  9. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. /**
  2. * Test whether a given object model is supported. Returns true if the object model
  3. * is the Saxon object model, DOM, JDOM, DOM4J, or XOM
  4. *
  5. * @param model The URI identifying the object model.
  6. * @return true if the object model is one of the following (provided that the supporting
  7. * JAR file is available on the classpath)
  8. * {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_SAXON},
  9. * {@link XPathConstants#DOM_OBJECT_MODEL},
  10. * {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_JDOM}, or
  11. * {@link NamespaceConstant#OBJECT_MODEL_XOM}, or
  12. * {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_DOM4J}.
  13. * Saxon also allows user-defined external object models to be registered with the Configuration, and
  14. * this method will return true in respect of any such model.
  15. */
  16. public boolean isObjectModelSupported(String model) {
  17. boolean debug = System.getProperty("jaxp.debug") != null;
  18. boolean result = silentIsObjectModelSupported(model);
  19. if (debug) {
  20. System.err.println("JAXP: Calling " + getClass().getName() + ".isObjectModelSupported(\"" + model + "\")");
  21. System.err.println("JAXP: -- returning " + (result ? "true" : "false (check all required libraries are on the class path"));
  22. }
  23. return result;
  24. }

代码示例来源:origin: org.jboss.soa.bpel/riftsaw-bpel-runtime

  1. JaxpVariableResolver varResolver = new JaxpVariableResolver(ctx, oxpath20, ((XPathFactoryImpl) _xpf).getConfiguration());
  2. XPath xpe = _xpf.newXPath();
  3. xpe.setXPathFunctionResolver(funcResolver);
  4. XPath20ExpressionModifier modifier = new XPath20ExpressionModifier(oxpath20.namespaceCtx, ((XPathFactoryImpl) _xpf).getConfiguration().getNamePool());

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon

  1. /**
  2. * Default constructor: this creates a Configuration as well as creating the XPathFactory. Any documents
  3. * accessed using this XPathFactory must be built using this same Configuration.
  4. */
  5. public XPathFactoryImpl() {
  6. config = Configuration.newConfiguration();
  7. setConfiguration(config);
  8. Version.platform.registerAllBuiltInObjectModels(config);
  9. }

代码示例来源:origin: net.sf.saxon/Saxon-HE

  1. /**
  2. * Test whether a given object model is supported. Returns true if the object model
  3. * is the Saxon object model, DOM, JDOM, DOM4J, or XOM
  4. *
  5. * @param model The URI identifying the object model.
  6. * @return true if the object model is one of the following (provided that the supporting
  7. * JAR file is available on the classpath)
  8. * {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_SAXON},
  9. * {@link XPathConstants#DOM_OBJECT_MODEL},
  10. * {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_JDOM}, or
  11. * {@link NamespaceConstant#OBJECT_MODEL_XOM}, or
  12. * {@link net.sf.saxon.lib.NamespaceConstant#OBJECT_MODEL_DOM4J}.
  13. * Saxon also allows user-defined external object models to be registered with the Configuration, and
  14. * this method will return true in respect of any such model.
  15. */
  16. public boolean isObjectModelSupported(String model) {
  17. boolean debug = System.getProperty("jaxp.debug") != null;
  18. boolean result = silentIsObjectModelSupported(model);
  19. if (debug) {
  20. System.err.println("JAXP: Calling " + getClass().getName() + ".isObjectModelSupported(\"" + model + "\")");
  21. System.err.println("JAXP: -- returning " + (result ? "true" : "false (check all required libraries are on the class path"));
  22. }
  23. return result;
  24. }

代码示例来源:origin: org.mule.modules/mule-module-xml

  1. /**
  2. * {@inheritDoc}
  3. * Returns instances of {@link XPathFactoryImpl}
  4. */
  5. @Override
  6. protected XPathFactory createXPathFactory()
  7. {
  8. return new XPathFactoryImpl();
  9. }
  10. }

代码示例来源:origin: goldmansachs/jdmn

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: goldmansachs/jdmn

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: goldmansachs/jdmn

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: goldmansachs/jdmn

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: goldmansachs/jdmn

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core

  1. private String evaluateXPath(String input, String expression) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {
  2. // Read document
  3. String xml = "<root>" + input + "</root>";
  4. DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
  5. DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
  6. InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
  7. Document document = docBuilder.parse(inputStream);
  8. // Evaluate xpath
  9. XPathFactory xPathFactory = new XPathFactoryImpl();
  10. XPath xPath = xPathFactory.newXPath();
  11. return xPath.evaluate(expression, document.getDocumentElement());
  12. }

代码示例来源:origin: org.mule.runtime/mule-module-extensions-spring-support

  1. @Before
  2. public void before() throws Exception {
  3. XPathFactory xpathFactory = new XPathFactoryImpl();
  4. xpath = xpathFactory.newXPath();
  5. builderFactory = DocumentBuilderFactory.newInstance();
  6. builderFactory.setNamespaceAware(true);
  7. }

相关文章