Java XPath Create getXPathFactory()

Here you can find the source of getXPathFactory()

Description

get X Path Factory

License

LGPL

Declaration

private static XPathFactory getXPathFactory() throws XPathFactoryConfigurationException 

Method Source Code

//package com.java2s;
/*// w w  w . ja v  a 2 s.  c  o  m
 * JLib - Publicitas Java library.
 *
 * Copyright (c) 2005, 2006, 2007, 2008 Publicitas SA.
 * Licensed under LGPL (LGPL-LICENSE.txt) license.
 */

import javax.xml.xpath.XPathConstants;

import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPathFactoryConfigurationException;

public class Main {
    private static XPathFactory _xPathFactory;

    private static XPathFactory getXPathFactory() throws XPathFactoryConfigurationException {
        if (_xPathFactory == null) {
            String magicValue = System
                    .getProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom");
            System.setProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom",
                    "net.sf.saxon.xpath.XPathFactoryImpl");
            //          System.setProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom","org.apache.xpath.jaxp.XPathFactoryImpl");
            //          System.setProperty("jaxp.debug","yes");
            _xPathFactory = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL);
            if (magicValue == null)
                System.clearProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom");
            else
                System.setProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom", magicValue);
        }
        return _xPathFactory;
    }
}

Related

  1. getXPathExprFromNode(Node node)
  2. getXPathExprFromNode(Node node)
  3. getXPathFactory()
  4. getXPathFactory()
  5. getXPathFactory()
  6. getXpathFilter(String xpath, Map namespaceMap)
  7. getXPathForElement(Node e, NamespaceContext ctx)
  8. getXPathForNode(Node node)
  9. getXPathForNode(Node node)