Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/XMLUtils.java @ 23:00596a591a2f
Added possibibilty to ceate XPaths with namespace contextes.
artifacts/trunk@57 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 10 Sep 2009 08:14:03 +0000 |
parents | ff666592c1c3 |
children | ccc6aae25585 |
comparison
equal
deleted
inserted
replaced
22:72abee95fd64 | 23:00596a591a2f |
---|---|
7 import javax.xml.parsers.DocumentBuilderFactory; | 7 import javax.xml.parsers.DocumentBuilderFactory; |
8 | 8 |
9 import javax.xml.parsers.ParserConfigurationException; | 9 import javax.xml.parsers.ParserConfigurationException; |
10 | 10 |
11 import org.apache.log4j.Logger; | 11 import org.apache.log4j.Logger; |
12 | |
13 import javax.xml.xpath.XPathFactory; | |
14 import javax.xml.xpath.XPath; | |
15 | |
16 import javax.xml.namespace.NamespaceContext; | |
17 | |
12 | 18 |
13 /** | 19 /** |
14 * @author Sascha L. Teichmann | 20 * @author Sascha L. Teichmann |
15 */ | 21 */ |
16 public final class XMLUtils | 22 public final class XMLUtils |
56 catch (ParserConfigurationException pce) { | 62 catch (ParserConfigurationException pce) { |
57 logger.error(pce.getLocalizedMessage(), pce); | 63 logger.error(pce.getLocalizedMessage(), pce); |
58 } | 64 } |
59 return null; | 65 return null; |
60 } | 66 } |
67 | |
68 public static final XPath newXPath() { | |
69 return newXPath(null); | |
70 } | |
71 | |
72 public static final XPath newXPath(NamespaceContext namespaceContext) { | |
73 XPathFactory factory = XPathFactory.newInstance(); | |
74 XPath xpath = factory.newXPath(); | |
75 if (namespaceContext != null) { | |
76 xpath.setNamespaceContext(namespaceContext); | |
77 } | |
78 return xpath; | |
79 } | |
61 } | 80 } |
62 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: | 81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |