Skip to content

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

@rsteph-de

Description

@rsteph-de

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

.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions