commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Sklyut <Dmitry_Skl...@orcom.com>
Subject RE: [JXPath] Which type of object does "count()" return?
Date Wed, 07 Jan 2004 14:48:27 GMT
Why don't you change your code like this and see:

JXPathContext context = JXPathContext.newContext(doc);
  // doc is a JDOM tree
  System.out.print("JXTest: ");
  Object result = context.getValue("count(//List/Item)"));
  System.out.println("Result: " + result);
  if (result != null)
  System.out.println("Result class type: " + result.getClass().getName());

I haven't had the need yet to do a count as of yet.  So I can't tell you of
the bat.

Dmitry

-----Original Message-----
From: Christian Janoff [mailto:misc@janoff.de]
Sent: Tuesday, January 06, 2004 6:46 PM
To: Jakarta Commons Users List
Subject: [JXPath] Which type of object does "count()" return?


Hi there!

I'm using commons-jxpath-1.1. Everytime I try to execute

  context.getValue("count(//List/Item)")

I get a java.lang.ClassCastException.

The XML looks like this:

  <?xml version="1.0" encoding="UTF-8"?>
  <List>
    <Item>
      <Name>xyz</Name>
      <Name2>abc</Name>
    </Item>
  </List>

The code looks like this:

  JXPathContext context = JXPathContext.newContext(doc);
  // doc is a JDOM tree
  System.out.print("JXTest: ");
  System.out.println((String)context.getValue("count(//List/Item)"));

(I also tried Integer instead of String.)

Which type of object does the getValue() method return after "count"
has been executed?

Thanks for any hints!
Christian.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message