comparison artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java @ 25:ccc6aae25585

Moved some XPath stuff from Config into XMLUtils. artifacts/trunk@59 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 10 Sep 2009 09:23:53 +0000
parents 00596a591a2f
children c2fc85e55f9f
comparison
equal deleted inserted replaced
24:d5dc2900392f 25:ccc6aae25585
8 import org.w3c.dom.Node; 8 import org.w3c.dom.Node;
9 9
10 import org.xml.sax.SAXException; 10 import org.xml.sax.SAXException;
11 11
12 import javax.xml.parsers.DocumentBuilderFactory; 12 import javax.xml.parsers.DocumentBuilderFactory;
13
14 import javax.xml.parsers.ParserConfigurationException; 13 import javax.xml.parsers.ParserConfigurationException;
15 14
16 import javax.xml.namespace.QName; 15 import javax.xml.namespace.QName;
17 16
18 import javax.xml.xpath.XPathExpressionException;
19 import javax.xml.xpath.XPathConstants; 17 import javax.xml.xpath.XPathConstants;
20 18
21 import org.apache.log4j.Logger; 19 import org.apache.log4j.Logger;
22 20
23 /** 21 /**
93 } 91 }
94 92
95 public static final Object getXPath( 93 public static final Object getXPath(
96 Object root, String query, QName returnType 94 Object root, String query, QName returnType
97 ) { 95 ) {
98 if (root == null) { 96 return XMLUtils.xpath(root, query, returnType);
99 return null;
100 }
101
102 try {
103 return XMLUtils.newXPath().evaluate(query, root, returnType);
104 }
105 catch (XPathExpressionException xpee) {
106 logger.error(xpee.getLocalizedMessage(), xpee);
107 }
108
109 return null;
110 } 97 }
111 98
112 public static final Object getXPath(String query, QName returnType) { 99 public static final Object getXPath(String query, QName returnType) {
113 return getXPath(getConfig(), query, returnType); 100 return XMLUtils.xpath(getConfig(), query, returnType);
114 } 101 }
115 102
116 public static final NodeList getNodeSetXPath(String query) { 103 public static final NodeList getNodeSetXPath(String query) {
117 return (NodeList)getXPath(query, XPathConstants.NODESET); 104 return (NodeList)getXPath(query, XPathConstants.NODESET);
118 } 105 }

http://dive4elements.wald.intevation.org