Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Xpath that returns numeric values

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT ibiblio.org>
  • To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Xpath that returns numeric values
  • Date: Thu, 23 Feb 2012 12:21:31 -0500

On Wed, Feb 22, 2012 at 12:30 PM, Christophe Marchand
<christophe.marchand AT axyus.com> wrote:
> Hi !
>
> Element.query("count(//document[@imported])"); throws this exception :
> nu.xom.XPathTypeException: XPath expression count(//document[@imported])
> returned a java.lang.Double instead of a node-set.
>         at nu.xom.JaxenConnector.selectNodes(Unknown Source)
>         at nu.xom.Node.query(Unknown Source)
>         at nu.xom.Node.query(Unknown Source)
>
> Is there a workaround, or should I use
> Element.query("count(//document[@imported])").size() instead ?
>
> Which workaround for avg(...) functions ?

This is working as intended. Java's strict typing really doesn't deal
well with XPath's loose typing. The workaround is to do math in Java
rather than in XPath.

--
Elliotte Rusty Harold
elharo AT ibiblio.org




Archive powered by MHonArc 2.6.24.

Top of Page