Jasper Reports use Xpath functions - xpath

We are using Jasper Report's xml datasource. To create some output, we would need the XPath distinct-values() function, as described. If I use it like described, Jasper Studio gives me an error:
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression : Source text : ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDa‌​taSource("distinct-values(/connections/message/type)")
Does anyone know how to use XPath functions in Jasper Reports, jrxml files?

distinct-values() is a function that is exclusive to XPath 2.0. Unfortunately, Jasper Reports only support XPath 1.0 (ironically, the forum post is about exactly the same thing).
The short answer is: no, there is no XPath 1.0 function that eliminates duplicate values from a set of nodes.
There might be ways around this problem, if you can show more of your input XML document.
EDIT: For the record, here is the answer the OP got from the Jasper Reports Forum:
Hi, I talked with JR Team in order to better clarify the topic. So currently the version supported is XPath version 1.0. This because JR relies on Xalan or Jaxen for XPath support. These thirdy-part libraries currently support version 1.0.
Looking at the Jaxen FAQ it seems to be a "strict" decision they made, focusing only on compatibility support: http://jaxen.codehaus.org/faq.html
Which version of XPath does jaxen support? Does jaxen support XPath 2?
jaxen supports XPath 1.0. It does not support XPath 2.0. XPath 2.0 is a very different spec with many things to recommend it and a few things not to like as well. However XPath 2.0 is not compatible with XPath 1.0. It is far from a simple upgrade from XPath 1.0. It has a very different data model, that might well require significant revisions to jaxen's internal data structures, and possibly a very different API as well.
The current release plan focuses exclusively on XPath 1.0 compatibility. Perhaps one day someone will make a branch or fork of jaxen that supports XPath 2. However, this would be a significant undertaking, and so far little interest in this has been shown.
Therefore for the moment we will stay with version 1.0 of XPath
I disagree with the "a few things not to like" about XPath 2.0, but it is a clear answer, at least.

Related

How to check D3 version?

This question is not an exact duplicate, it is a "translation hub" for non-obvious questions:
About core version: this question is about "How to check at runtime", but there are good answer at this other question: "How to find the exact version of D3 given the minified file?".
About module version: "D3 is a collection of modules" (see official D3 API documentation), module is the correct term, but you can use this question: "How to find out about loaded d3.js extensions and their versions at runtime?".
There is a property like d3.version for "core version"? or some "per module" property or method to check version? (imagining for example something like d3.csv.version)
The API docs show nothing about it.
PS: supposing that it is stable and can be checked for example in embedded D3 like Plotly.d3.
You're correct, you can figure out the version using d3.version.
Just checked using console.log(d3) to see all the methods and properties available, and version was listed.
Here's a fiddle: https://jsfiddle.net/3e42bxom/2/

Xpath 2.0 online Checker

Is there any plugin or software where i can check the functions of Xpath 2.0 ??
Currently i am using Xpath Checker (ff Plugin) which only supports Xpath 1.0.
There is an online XPath 2.0 tool called PathEnq that might suit.
The tool runs client-side by using the Saxon-CE XSLT 2.0 processor (a JavaScript application) as a 'host' and dynamically generating XSLT based on your expression. XPath variables and namespaces are supported.
I'm using online xpath tester xpather which works really nice.
Note: It's xpath 2.0 support is currently in beta.

Itextsharp documentation for xml

I am looking for documentation on the XML parser in ItextSharp, I heard there was a dtd years ago but this seems to be defunt. Does anyone know where I can find out all the valid tags and references?
I am using ItextSharp with Spark
Thanks
When in doubt, use the source. Poking around in my copy of the current iText source, I see that the only SimpleXMLDocHandler available is HTMLWorker.
And if you look at the source for HtmlTags.cs, you'll see all the tag and attribute constants HTMLWorker uses.
It's not exactly comprehensive, but is going to be getting some Enhancement in the immediate future.
I don't see a 4.1.2 tag, but there's one for 4.1.6 in the iTextSharp project on SF. It shows ITextHandler using a bunch of constants from ElementTag in HandleStartingTags(). It also uses ElementFactory to build the various supported tags. Looking at the source for each function will tell you which attributes it supports.

Can I use xpath 2.0 with firefox and selenium?

I saw other questions referring to xpath 2.0, which apparently simplifies string expressions. I'm using Firefox 3.5.5 and selenium 1.0.1.
How can I check if my versions of Firefox and Selenium support it?
Does Selenium defer to Firefox's built-in Xpath implementation?
In that case, if I start using another (perhaps older) browser with selenium, will I run into problems by expecting xpath 2.0?
By default, selenium uses the "native" version of XPath that comes with the browser. You can make it use a version that comes with Selenium, written in JavaScript. This seems to implement XPath 1.0, based on glancing at the source.
I think there is a jQuery plugin that gives you support for XPath 2.0. So, theoretically, if you inject jQuery and the plugin into your browser, maybe you could call XPath 2.0 commands with a JavascriptExecutor. Really, its probably not necessary though, but might be fun to play with.
Currently no browsers support XPath 2.0. To allow the use of a version that comes with Selenium, written in JavaScript, as suggested by #paul-biggar, use the following command :
allowNativeXpath(false)
more informations here :
http://www.seleniumwiki.com/software-testing/selenium-ide-allownativexpath/

Is Linq to NHibernate in the 2.1 Alpha release?

So the nHibernate 2.1 Alpha came out a few days ago, but the announcement on sourceforge doesn't mention the additional features. In particular, it doesn't mention whether LINQ is included. I know that I've read that LINQ would be part of 2.1, but that was 6 months ago. Anybody know if LINQ is in 2.1 or what new features are? There's no documenation about 2.1 alpha features on the official site.
LinqToNHibernate is being written by Steve Strong at IMeta. Steve is attempting an amazing task by changing the way NHibernate parses HQL from the string based system to an abstract syntax tree. To be fair he does have a head start as this is being done in Hibernate using ANTLR which he is porting to .Net. It still baffles my mind what he is undertaking. I must say well done to IMeta for giving Steve the time to work on this.
If you want to see how far he is going you can check the uNhAddIns repository.
There is also a workable LinqToNHibernate provider which you'll find in NHContrib I am using this on a few projects and it works well but isn't in active development now and does break down if you attempt complex Linq queries

Resources