Firstly, 8.8 is rather an old version. Please try to reproduce the problem with a later version if you can.
One possibility is that you are hitting a bug such as
Also, please check that you are actually loading Saxon as the XPath engine, by displaying the class name of the returned "factory" variable.
Michael Kay

From: [] On Behalf Of Rakesh guttal
Sent: 27 February 2008 18:15
To: Michael Kay;
Subject: [saxon] Issue with XPATH evaluate

Hi Michael,

I am using saxon 8.8 version of your saxon product.
In order to improve the performance , i am using saxon's net.sf.saxon.xpath.XPathFactoryImpl for xpath querying.

here goes Test java file.

public class Test {
        private XPathFactory      factory = null;
     private XPath           xpath = null;
     public static void main(String[] args) {
          XPathFactory      factory = null;
          XPath           xpath = null;
          String objectModel=XPathConstants.DOM_OBJECT_MODEL;
          try {
               factory      = XPathFactory.newInstance(objectModel);
          } catch (XPathFactoryConfigurationException e1) {
          xpath           = factory.newXPath();
          Document document = null;
         try {
              System.out.println("before documentbuild");
           DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
           DocumentBuilder db = dbf.newDocumentBuilder();
           Test a = new Test();
           InputStream is = a.getResourceAsInputStream("IUFReportSchema.xsd");
           document = db.parse(is);
           Node root = document.getDocumentElement();
           NodeList elements = null;
           String query = "element[@name='option']";
           XPathExpression xpthQuery=xpath.compile(query);
           elements = (NodeList)xpthQuery.evaluate( root, XPathConstants.NODESET);
           System.out.println("elements size:"+elements.getLength());
           //"Resource file parsed " + filename);
         catch (Exception e) {
           // log.error("Problem parsing [" + filename + "]");
           //log.error("Exception: "+e.getMessage());

  public InputStream getResourceAsInputStream(String filename) {
         return getClass().getClassLoader().getResourceAsStream  (filename);

when I run above java file with saxon8-xpath.jar on classpath,i get the below output (which is expected)

elements size:1

But, when I run this file with saxon8-xpath.jar & saxon8sa.jar, i get an unexpected output.

elements size:0

Why is that when i include saxon8sa.jar apart from saxon8-xpath.jar on classpath, it affects the xpath querying result? it's not able to find an element with name "option" and it returns nodelist of size 0.