[jdom-interest] XPath selectNodes() returns empty List

Leyzerzon, Simeon simeon.leyzerzon at csfb.com
Tue Oct 18 10:18:57 PDT 2005


I'm having a problem and don't seem to be able to find the cause of it.  
Here are the details.

I'm processing the following xml file insided of a Java program using JDOM 1.0

<?xml version="1.0" encoding="UTF-8"?>
<!--<!DOCTYPE decision-process SYSTEM "decision-process.dtd">-->
	<decision type="primitive" id="fppLogic">
	<decision type="primitive" id="sellExists">
	<decision type="primitive" id="outstanding">
	<decision type="composite" id="outstandingComposite">
		<!--<decision type="primitive" name="sellExists">
		<decision ref="sellExists"/>
		<decision ref="outstanding"/>

The following is the xpath string I'm evaluating:

//decision [@id =//decision [supporting-class='com.csfb.fao.clr.calc.rule.OutstandingComposite']/decision/@ref/text()]/supporting-class/text()

The problem is that inside my Java code the List of nodes doesn't get populated and stays empty whereas when I'm using XPath Explorer from http://www.purpletech.com/xpe/index.jsp

it returns the expected list of supporting classes:


I'm using the following syntax in my Java code where xpathString is the expression mentioned above:

XPath x = XPath.newInstance(xpathString);
result = x.selectNodes(doc);

and the result returns empty.

I've been experimenting with passing different expressions in the hopes of maybe figuring this behavior out, and found out
that this expression works:

//decision [supporting-class='com.csfb.fao.clr.calc.rule.OutstandingComposite']/decision/@ref

but as soon as I add text() onto it, it stops working in Java, that is

//decision [supporting-class='com.csfb.fao.clr.calc.rule.OutstandingComposite']/decision/@ref/text() doesn't work.

XPath Explorer works in every case.

Please give me a hand as I don't want to resort to handcoding a bunch of loops inside of my Java code if I could use a simple XPath expression instead.

Thank you very much in advance!

> Simeon Leyzerzon
> Risk IT
> CREDIT | First 
>       SUISSE | Boston
      Tel: 212-538-7518

Please access the attached hyperlink for an important electronic communications disclaimer: 



More information about the jdom-interest mailing list