Java 类javax.xml.xpath.XPathFactoryConfigurationException 实例源码
项目:OpenJSharp
文件:XmlFactory.java
/**
* Returns properly configured (e.g. security features) factory
* - securityProcessing == is set based on security processing property, default is true
*/
public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException {
try {
XPathFactory factory = XPathFactory.newInstance();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory);
}
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
return factory;
} catch (XPathFactoryConfigurationException ex) {
LOGGER.log(Level.SEVERE, null, ex);
throw new IllegalStateException( ex);
} catch (AbstractMethodError er) {
LOGGER.log(Level.SEVERE, null, er);
throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er);
}
}
项目:jdk8u-jdk
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:openjdk-jdk10
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:openjdk-jdk10
文件:XmlFactory.java
/**
* Returns properly configured (e.g. security features) factory
* - securityProcessing == is set based on security processing property, default is true
*/
public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException {
try {
XPathFactory factory = XPathFactory.newInstance();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory);
}
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
return factory;
} catch (XPathFactoryConfigurationException ex) {
LOGGER.log(Level.SEVERE, null, ex);
throw new IllegalStateException( ex);
} catch (AbstractMethodError er) {
LOGGER.log(Level.SEVERE, null, er);
throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er);
}
}
项目:openjdk9
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:openjdk9
文件:XmlFactory.java
/**
* Returns properly configured (e.g. security features) factory
* - securityProcessing == is set based on security processing property, default is true
*/
public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException {
try {
XPathFactory factory = XPathFactory.newInstance();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory);
}
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
return factory;
} catch (XPathFactoryConfigurationException ex) {
LOGGER.log(Level.SEVERE, null, ex);
throw new IllegalStateException( ex);
} catch (AbstractMethodError er) {
LOGGER.log(Level.SEVERE, null, er);
throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er);
}
}
项目:TranskribusCore
文件:TrpXPathProcessor.java
public TrpXPathProcessor(final String docBuilderFactoryImpl, final String xPathFactoryImpl)
throws XPathFactoryConfigurationException, ParserConfigurationException {
if(docBuilderFactoryImpl == null || xPathFactoryImpl == null) {
throw new IllegalArgumentException("Arguments must not be null!");
}
classLoader = this.getClass().getClassLoader();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(
docBuilderFactoryImpl,
classLoader);
builder = factory.newDocumentBuilder();
xPathFactory = XPathFactory.newInstance(
javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI,
xPathFactoryImpl,
classLoader
);
xPath = xPathFactory.newXPath();
}
项目:jdk8u_jdk
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:lookaside_java-1.8.0-openjdk
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:lookaside_java-1.8.0-openjdk
文件:XmlFactory.java
/**
* Returns properly configured (e.g. security features) factory
* - securityProcessing == is set based on security processing property, default is true
*/
public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException {
try {
XPathFactory factory = XPathFactory.newInstance();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory);
}
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
return factory;
} catch (XPathFactoryConfigurationException ex) {
LOGGER.log(Level.SEVERE, null, ex);
throw new IllegalStateException( ex);
} catch (AbstractMethodError er) {
LOGGER.log(Level.SEVERE, null, er);
throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er);
}
}
项目:Camel
文件:XPathBuilder.java
protected static XPathFactory createDefaultXPathFactory() throws XPathFactoryConfigurationException {
XPathFactory factory = null;
// read system property and see if there is a factory set
Properties properties = System.getProperties();
for (Map.Entry<Object, Object> prop : properties.entrySet()) {
String key = (String) prop.getKey();
if (key.startsWith(XPathFactory.DEFAULT_PROPERTY_NAME)) {
String uri = ObjectHelper.after(key, ":");
if (uri != null) {
factory = XPathFactory.newInstance(uri);
LOG.info("Using system property {} with value {} when created default XPathFactory {}", new Object[]{key, uri, factory});
}
}
}
if (factory == null) {
factory = XPathFactory.newInstance();
LOG.info("Created default XPathFactory {}", factory);
}
return factory;
}
项目:contestparser
文件:HolidayEndpoint.java
@Autowired
public HolidayEndpoint(HumanResourceService humanResourceService)
throws JDOMException, XPathFactoryConfigurationException,
XPathExpressionException {
this.humanResourceService = humanResourceService;
Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI);
XPathFactory xPathFactory = XPathFactory.instance();
this.startDateExpression = xPathFactory.compile("//hr:StartDate",
Filters.element(), null, namespace);
this.endDateExpression = xPathFactory.compile("//hr:EndDate", Filters.element(),
null, namespace);
this.nameExpression = xPathFactory.compile(
"concat(//hr:FirstName,' ',//hr:LastName)", Filters.fstring(), null,
namespace);
}
项目:infobip-open-jdk-8
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:infobip-open-jdk-8
文件:XmlFactory.java
/**
* Returns properly configured (e.g. security features) factory
* - securityProcessing == is set based on security processing property, default is true
*/
public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException {
try {
XPathFactory factory = XPathFactory.newInstance();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory);
}
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
return factory;
} catch (XPathFactoryConfigurationException ex) {
LOGGER.log(Level.SEVERE, null, ex);
throw new IllegalStateException( ex);
} catch (AbstractMethodError er) {
LOGGER.log(Level.SEVERE, null, er);
throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er);
}
}
项目:jdk8u-dev-jdk
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:OLD-OpenJDK8
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:OLD-OpenJDK8
文件:XmlFactory.java
/**
* Returns properly configured (e.g. security features) factory
* - securityProcessing == is set based on security processing property, default is true
*/
public static XPathFactory createXPathFactory(boolean disableSecureProcessing) throws IllegalStateException {
try {
XPathFactory factory = XPathFactory.newInstance();
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "XPathFactory instance: {0}", factory);
}
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !isXMLSecurityDisabled(disableSecureProcessing));
return factory;
} catch (XPathFactoryConfigurationException ex) {
LOGGER.log(Level.SEVERE, null, ex);
throw new IllegalStateException( ex);
} catch (AbstractMethodError er) {
LOGGER.log(Level.SEVERE, null, er);
throw new IllegalStateException(Messages.INVALID_JAXP_IMPLEMENTATION.format(), er);
}
}
项目:openjdk-jdk7u-jdk
文件:XPathExFuncTest.java
/**
* Security is enabled, extension function not allowed
*/
public void testExtFuncNotAllowed() {
Policy p = new SimplePolicy(new AllPermission());
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
try {
evaluate(false);
} catch (XPathFactoryConfigurationException e) {
fail(e.getMessage());
} catch (XPathExpressionException ex) {
//expected since extension function is disallowed
System.out.println("testExtFuncNotAllowed: OK");
} finally {
System.setSecurityManager(null);
}
}
项目:geopackager
文件:RealWMTS.java
private WMTSLayerInfo parseCapabilities() throws IOException, ParserConfigurationException, SAXException, XPathExpressionException, XPathFactoryConfigurationException {
String uri = capabilitiesUrl;
WMTSCapabilitiesDocument capabilities = new WMTSCapabilitiesDocument(uri);
capabilities.scanTileMatrixSet(tileMatrixSet, new TileMatrixSetScanner() {
@Override
public void onTileMatrix(String identifier, double scaleDenom, double ulx, double uly,
int tileWidth, int tileHeight, int matrixWidth, int matrixHeight) {
tileMatrices.add(
new WMTSTileMatrix(identifier, scaleDenom, ulx, uly,
tileWidth, tileHeight, matrixWidth, matrixHeight));
}
});
return capabilities.getLayerInfo(layerName);
}
项目:bpp
文件:TestRunner.java
private boolean isContained(TestAssertion assertion, String fileLocation)
throws XPathExpressionException,
XPathFactoryConfigurationException, XPathException {
XPathFactory xpathFactory = XPathFactory
.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON);
XPathEvaluator xpath = (XPathEvaluator) xpathFactory.newXPath();
xpath.getConfiguration().setLineNumbering(true);
xpath.setNamespaceContext(new BpelNamespaceContext());
XPathExpression expr = xpath.compile(assertion.getTarget());
InputSource inputSource = new InputSource(
new File(fileLocation).toString());
SAXSource saxSource = new SAXSource(inputSource);
NodeInfo doc = xpath.getConfiguration().buildDocument(saxSource);
@SuppressWarnings("unchecked")
List<NodeInfo> matchedLines = (List<NodeInfo>) expr.evaluate(doc,
XPathConstants.NODESET);
if (matchedLines.size() > 0) {
return true;
}
return false;
}
项目:OpenJSharp
文件:XmlUtil.java
public static XPathFactory newXPathFactory(boolean secureXmlProcessingEnabled) {
XPathFactory factory = XPathFactory.newInstance();
try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, isXMLSecurityDisabled(secureXmlProcessingEnabled));
} catch (XPathFactoryConfigurationException e) {
LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } );
}
return factory;
}
项目:ChronoBike
文件:XmlHelper.java
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;
}
项目:jdk8u-jdk
文件:XPathExFuncTest.java
void evaluate(boolean enableExt) throws XPathFactoryConfigurationException, XPathExpressionException {
Document document = getDocument();
XPathFactory xPathFactory = XPathFactory.newInstance();
/**
* Use of the extension function 'http://exslt.org/strings:tokenize' is
* not allowed when the secure processing feature is set to true.
* Attempt to use the new property to enable extension function
*/
if (enableExt) {
boolean isExtensionSupported = enableExtensionFunction(xPathFactory);
}
xPathFactory.setXPathFunctionResolver(new MyXPathFunctionResolver());
if (System.getSecurityManager() == null) {
xPathFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
}
XPath xPath = xPathFactory.newXPath();
xPath.setNamespaceContext(new MyNamespaceContext());
String xPathResult = xPath.evaluate(XPATH_EXPRESSION, document);
System.out.println(
"XPath result (enableExtensionFunction == " + enableExt + ") = \""
+ xPathResult
+ "\"");
}
项目:jdk8u-jdk
文件:XPathExFuncTest.java
boolean enableExtensionFunction(XPathFactory factory) {
boolean isSupported = true;
try {
factory.setFeature(ENABLE_EXTENSION_FUNCTIONS, true);
} catch (XPathFactoryConfigurationException ex) {
isSupported = false;
}
return isSupported;
}
项目:openjdk-jdk10
文件:XPathExFuncTest.java
void evaluate(boolean enableExt) throws XPathFactoryConfigurationException, XPathExpressionException {
Document document = getDocument();
XPathFactory xPathFactory = XPathFactory.newInstance();
/**
* Use of the extension function 'http://exslt.org/strings:tokenize' is
* not allowed when the secure processing feature is set to true.
* Attempt to use the new property to enable extension function
*/
if (enableExt) {
boolean isExtensionSupported = enableExtensionFunction(xPathFactory);
}
xPathFactory.setXPathFunctionResolver(new MyXPathFunctionResolver());
if (System.getSecurityManager() == null) {
xPathFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
}
XPath xPath = xPathFactory.newXPath();
xPath.setNamespaceContext(new MyNamespaceContext());
String xPathResult = xPath.evaluate(XPATH_EXPRESSION, document);
System.out.println(
"XPath result (enableExtensionFunction == " + enableExt + ") = \""
+ xPathResult
+ "\"");
}
项目:openjdk-jdk10
文件:XPathExFuncTest.java
boolean enableExtensionFunction(XPathFactory factory) {
boolean isSupported = true;
try {
factory.setFeature(ENABLE_EXTENSION_FUNCTIONS, true);
} catch (XPathFactoryConfigurationException ex) {
isSupported = false;
}
return isSupported;
}
项目:openjdk-jdk10
文件:XmlUtil.java
public static XPathFactory newXPathFactory(boolean disableSecurity) {
XPathFactory factory = XPathFactory.newInstance();
try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity));
} catch (XPathFactoryConfigurationException e) {
LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } );
}
return factory;
}
项目:openjdk-jdk10
文件:Bug4992805.java
private XPath createXPath() throws XPathFactoryConfigurationException {
XPathFactory xpathFactory = XPathFactory.newInstance();
Assert.assertNotNull(xpathFactory);
XPath xpath = xpathFactory.newXPath();
Assert.assertNotNull(xpath);
return xpath;
}
项目:openjdk-jdk10
文件:Bug4992793.java
private XPath createXPath() throws XPathFactoryConfigurationException {
XPathFactory xpathFactory = XPathFactory.newInstance();
Assert.assertNotNull(xpathFactory);
XPath xpath = xpathFactory.newXPath();
Assert.assertNotNull(xpath);
return xpath;
}
项目:openjdk-jdk10
文件:Bug4992788.java
private XPath createXPath() throws XPathFactoryConfigurationException {
XPathFactory xpathFactory = XPathFactory.newInstance();
Assert.assertNotNull(xpathFactory);
XPath xpath = xpathFactory.newXPath();
Assert.assertNotNull(xpath);
return xpath;
}
项目:openjdk9
文件:XPathExFuncTest.java
void evaluate(boolean enableExt) throws XPathFactoryConfigurationException, XPathExpressionException {
Document document = getDocument();
XPathFactory xPathFactory = XPathFactory.newInstance();
/**
* Use of the extension function 'http://exslt.org/strings:tokenize' is
* not allowed when the secure processing feature is set to true.
* Attempt to use the new property to enable extension function
*/
if (enableExt) {
boolean isExtensionSupported = enableExtensionFunction(xPathFactory);
}
xPathFactory.setXPathFunctionResolver(new MyXPathFunctionResolver());
if (System.getSecurityManager() == null) {
xPathFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
}
XPath xPath = xPathFactory.newXPath();
xPath.setNamespaceContext(new MyNamespaceContext());
String xPathResult = xPath.evaluate(XPATH_EXPRESSION, document);
System.out.println(
"XPath result (enableExtensionFunction == " + enableExt + ") = \""
+ xPathResult
+ "\"");
}
项目:openjdk9
文件:XPathExFuncTest.java
boolean enableExtensionFunction(XPathFactory factory) {
boolean isSupported = true;
try {
factory.setFeature(ENABLE_EXTENSION_FUNCTIONS, true);
} catch (XPathFactoryConfigurationException ex) {
isSupported = false;
}
return isSupported;
}
项目:openjdk9
文件:XmlUtil.java
public static XPathFactory newXPathFactory(boolean disableSecurity) {
XPathFactory factory = XPathFactory.newInstance();
try {
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, !xmlSecurityDisabled(disableSecurity));
} catch (XPathFactoryConfigurationException e) {
LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support secure xml processing!", new Object[] { factory.getClass().getName() } );
}
return factory;
}
项目:openjdk9
文件:Bug4992805.java
private XPath createXPath() throws XPathFactoryConfigurationException {
XPathFactory xpathFactory = XPathFactory.newInstance();
Assert.assertNotNull(xpathFactory);
XPath xpath = xpathFactory.newXPath();
Assert.assertNotNull(xpath);
return xpath;
}
项目:openjdk9
文件:Bug4992793.java
private XPath createXPath() throws XPathFactoryConfigurationException {
XPathFactory xpathFactory = XPathFactory.newInstance();
Assert.assertNotNull(xpathFactory);
XPath xpath = xpathFactory.newXPath();
Assert.assertNotNull(xpath);
return xpath;
}
项目:openjdk9
文件:Bug4992788.java
private XPath createXPath() throws XPathFactoryConfigurationException {
XPathFactory xpathFactory = XPathFactory.newInstance();
Assert.assertNotNull(xpathFactory);
XPath xpath = xpathFactory.newXPath();
Assert.assertNotNull(xpath);
return xpath;
}
项目:TranskribusCore
文件:PageXmlProcessorFactory.java
public static PageXmlProcessor newInstance(DocBuilderFactoryImpl docBuilderFactoryImpl,
XPathFactoryImpl xPathFactoryImpl) throws XPathFactoryConfigurationException, ParserConfigurationException {
File store = new File(STORE_LOCATION);
if(store.isDirectory() && store.canRead()) {
logger.debug("Returning Instance with netShare access.");
return buildNetShareInstance(docBuilderFactoryImpl, xPathFactoryImpl);
} else {
logger.debug("Returning Instance with HTTPS access.");
return buildHttpInstance(docBuilderFactoryImpl, xPathFactoryImpl);
}
}
项目:TranskribusCore
文件:PageXmlProcessorFactory.java
private static PageXmlProcessor buildHttpInstance(DocBuilderFactoryImpl dbImpl, XPathFactoryImpl xpImpl) throws XPathFactoryConfigurationException, ParserConfigurationException {
return new PageXmlProcessor(dbImpl, xpImpl) {
@Override
protected Document loadDocument(final String xmlKey)
throws MalformedURLException, IllegalArgumentException, SAXException, IOException {
return super.parse(uriBuilder.getFileUri(xmlKey).toURL());
}
};
}
项目:TranskribusCore
文件:PageXmlProcessorFactory.java
private static PageXmlProcessor buildNetShareInstance(DocBuilderFactoryImpl dbImpl, XPathFactoryImpl xpImpl) throws XPathFactoryConfigurationException, ParserConfigurationException {
return new PageXmlProcessor(dbImpl, xpImpl) {
@Override
protected Document loadDocument(final String xmlKey)
throws MalformedURLException, IllegalArgumentException, SAXException, IOException {
File file = LocalFimagestoreClient.findFile(STORE_LOCATION, xmlKey);
return super.parse(file);
}
};
}
项目:TranskribusCore
文件:XPathTest.java
public static void main(String[] args) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException, XPathFactoryConfigurationException{
ClassLoader cl = XPathTest.class.getClassLoader();
// DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance("com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", cl);
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
// domFactory.setNamespaceAware(true);
// XPathFactory xpathFactory = XPathFactory.newInstance(javax.xml.xpath.XPathFactory.DEFAULT_OBJECT_MODEL_URI, "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", cl);
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
xpath.getNamespaceContext();
DocumentBuilder builder = domFactory.newDocumentBuilder();
File f = new File("/mnt/dea_scratch/TRP/test/Klassikerausgaben_test/page/bsb00087391_00009.xml");
Document catalog = builder.parse(f);
final XPathExpression expr = xpath.compile("//*[contains(name(), 'Page')]/@imageWidth");
// Object result = expr.evaluate(catalog, XPathConstants.NUMBER);
// Double res = (Double)result;
// System.out.println(res);
Object result = expr.evaluate(catalog, XPathConstants.STRING);
String res = (String)result;
System.out.println(res);
// Object result = expr.evaluate(catalog, XPathConstants.NODESET);
// NodeList nodes = (NodeList) result;
// if (nodes.getLength() > 0) {
// String[] parents = new String[nodes.getLength()];
// for (int i = 0; i < nodes.getLength(); i++) {
// parents[i] = nodes.item(i).getNodeValue();
// System.out.println(parents[i]);
// }
// }
}