jstl-api icon indicating copy to clipboard operation
jstl-api copied to clipboard

XML Tag Library: allow adding Namespaces to JSTLXPathNamespaceContext in XPathUtil

Open rsteph-de opened this issue 8 months ago • 1 comments

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).

darwin_jsp.txt

.

rsteph-de avatar Mar 03 '25 19:03 rsteph-de

In Progress: https://github.com/jakartaee/tags/issues/272

volosied avatar Oct 03 '25 15:10 volosied