Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Tag Library: allow adding Namespaces to JSTLXPathNamespaceContext in XPathUtil #272

Open
rsteph-de opened this issue Mar 3, 2025 · 0 comments

Comments

@rsteph-de
Copy link

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

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant