Java tutorial
//package com.java2s; /* * 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; } }