oroger Posted February 7, 2012 Share Posted February 7, 2012 Hi, I am currently trying the new namespace aware feature added in JasperReports 4.0.1. (see http://jasperforge.org/projects/jasperreports/tracker/view.php?id=4500). It is working fine after patching the JRXmlUtils class as indicated in the issue. However, I am having difficulties with a specific case where the dataset root element has an xmlns attribute with no prefix. In that specific case, the XPath query does not return the value. Since I have no prefix for the namespace I siply can get the value.Has someone already encountered this issue ? Code:<report xmlns="mynamespace">... <queryString language="xPath"> <![CDATA[/]]> </queryString> <field name="report" class="java.lang.String"> <fieldDescription><![CDATA[report]]></fieldDescription> </field> Link to comment Share on other sites More sharing options...
oroger Posted February 9, 2012 Author Share Posted February 9, 2012 According to the Xalan mainling list (http://old.nabble.com/XPath-with-default-namespace---No-result-tt33285727.html#a33285727) this behavior is expected. I understand why, <report/> and <report xmlns="{ns}" /> are different elements and should be accessed in two distinct ways.The solution I see would then be to provide a PrefixResolver as explained here : http://www.edankert.com/defaultnamespaces.html. I can do this by providing a different XalanXPathExecuterFactory that would have a PrefixResolved as attempted in that page http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=44911.The issue for me now is to be able to initialize the resolver with the XML input. At the moment I could just hardcode prefix / namespace mappings in the getNamespaceForPrefix(String prefix) which seems to be used over getNamespaceForPrefix(String prefix, org.w3c.dom.Node namespaceContext).JAXPPrefixResolver (http://www.docjar.com/html/api/com/sun/org/apache/xpath/internal/jaxp/JAXPPrefixResolver.java.html) does that kind of parsing but needs a namespaceContext at initialization, which is not provided by the Factory.Post Edited by oroger at 02/09/2012 16:41 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now