As a matter of principle, I would prefer it if you don't go off-list. Although the conversation might not interest everyone on the list, it's important that once the question is in the archives, the subsequent correspondence and final conclusion should also be in the archives.
 
If the System.out.println() line wasn't executed, then presumably an exception was thrown by the evaluate() call. It would be nice to know what that exception was. It should be easy for you to determine whether (a) the exception occurred during the call on evaluate(), or (b) it occurred when casting the result to a DOM NodeList.
 
It would be useful to verify that the XPath implementation returned by the factory is indeed the Saxon implementation. You can do this by printing the class name of the returned instance.
 
You should be able with Saxon 9.0 to rely on the fact that if node is an instance of org.w3.dom.Node, then evaluate(node, XPathConstants.NODESET) will return an instance of org.w3.dom.NodeList.
 
Michael Kay
http://www.saxonica.com/


From: Rakesh guttal [mailto:rak_mail2001@rediffmail.com]
Sent: 10 December 2007 11:28
To: Michael Kay
Subject: Re: RE: [saxon] Difference Between SAXON 8.8 and 9.0.0.1

Hi Michael,

Below is a part of code where i am facing some problems.

    NodeList resultList      = null;
    XPathFactory factory      = null;
    XPath xpath                = null;
    XPathExpression members = null;
       
    System.out.println("before setting system property");
    System.setProperty("javax.xml.xpath.XPathFactory:"+XPathConstants.DOM_OBJECT_MODEL,"net.sf.saxon.xpath.XPathFactoryImpl");
    System.setProperty("javax.xml.transform.TransformerFactory","net.sf.saxon.TransformerFactoryImpl");
    String objectModel=XPathConstants.DOM_OBJECT_MODEL;
       
 
     try {
          factory      = XPathFactory.newInstance(objectModel);
     } catch (XPathFactoryConfigurationException e1) {
          System.out.println("exception thrown");
          e1.printStackTrace();
     }
     xpath           = factory.newXPath();
             
     
      members = xpath.compile("(. | *)[count(@*)=0 or count(@code)>0 or count(@size)>0 or count(@countryId)>0]");
     
      Node node=resultList.item(i);

        System.out.println("before members.evaluate, node: "+node);
        // elements of bo tag
        NodeList children = (NodeList) members.evaluate(node, XPathConstants.NODESET);
        System.out.println("after members.evaluate "); 

Note: node contains just one element.

when using SAXON 8.8 (report is generated successfully), I get below output

before members.evaluate, node: [option:null]
after members.evaluate

when using SAXON 9.0. Jars used on classpath saxon9-dom.jar,saxon9sa.jar , saxon-xpath.jar & directory which contains license file. I get below output

before members.evaluate, node: [option:null]

It doesn't print the message "after members.evalute()" message.

Does the newer version of SAXON doesn't return nodelist if source node contain only one element?

Thanks in advance,
Rakesh



On Mon, 10 Dec 2007 Michael Kay wrote :
>There's no attachment. If you need to submit attachments it's best to do it
>using the support-requests tracker on SourceForge. However, if you can then
>it's better to try and cut the problem down to a few lines to make it easier
>to see what's going on.
>
>There have been quite a few changes in the XPath APIs between Saxon 8.8 and
>Saxon 9.0 in an attempt to improve conformance with the JAXP specifications
>while still supporting use of XPath 2.0 and non-DOM object models. You
>should find most of these changes described in the change logs for the
>various releases.
>
>Michael Kay
>http://www.saxonica.com/
>
>
>  _____
>
> From: saxon-help-bounces@lists.sourceforge.net
>[mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of Rakesh guttal
>Sent: 10 December 2007 07:24
>To: saxon-help@lists.sourceforge.net
>Subject: [saxon] Difference Between SAXON 8.8 and 9.0.0.1
>
>
>
>
>Hi,
>
>I am using using J.D.K 1.4.2 and SAXON 8.8.
>
>I use XPATH, XSLT API's.
>
>Every thing was working fine with SAXON 8.8. But, when I tried to use SAXON
>9.0.0.1 it is not working correctly.
>
>Please find attached the XMLResultSet.java file where i am using XPATH,
>XSLT.
>
>Line number on which It is failing is 189.
>
>NodeList children=(NodeList)members.evaluate(node,XPathConstants.NODESET).
>
>It is not printing the System.out message after this line, when using SAXON
>9.0.0.1. But it works fine with SAXON 8.8.
>
>Please Provide any information regarding this.
>
>Thanks & Regards,
>Rakesh
>
>
>
>
>
>
>
><http://adworks.rediff.com/cgi-bin/AdWorks/click.cgi/www.rediff.com/signatur
>e-home.htm/1050715198@Middle5/1961853_1954773/1961358/1?PARTNER=3&OAS_QUERY=
>null target=new> Shaadi
>



Shaadi