jstl-api
jstl-api copied to clipboard
XML Tag Library: allow adding Namespaces to JSTLXPathNamespaceContext in XPathUtil
Could you make it possible to add custom XML namespaces to the default NamespaceContext, used when working with XPath expressions in the XML Tag library. This would make the processing of XML data with namespaces a lot easier.
The simplest solution would be a new public static method in org.apache.taglibs.standard.tag.common.xml.XPathUtil:
(Source)
public static void addNamespaceToXPathNamespaceContext(String prefix, String uri) {
JSTL_XPATH_NS_CTX.addNamespace(prefix, uri);
}
Of course, it would be more elegant if someone could inject and configure a custom NamespaceContext. But in my opinion that's not necessary.
Currently I work around the issue with Java Reflection to access the HashMap of Namespaces within the JSTLXPathNamespaceContext (see attachment).
.
In Progress: https://github.com/jakartaee/tags/issues/272