Hi,

I am trying to use net.saxon.xqj package for Xquery. I am using the result Sequence to get Item as Stream  and then get its location. But I am getting -1 everytime. Please help, should i use s9Api    or i can get line number through Xqj also.


    public void runQuery() {

        try {
            SaxonXQConnection con = (SaxonXQConnection) xqueryConnection.getConnection();
            con.getStaticContext().declareNamespace("xbrli", "http://www.xbrl.org/2003/instance");
            con.getStaticContext().declareNamespace("bvf", "http://www.biovail.com/2008-12-31");
            con.getStaticContext().declareNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            con.getStaticContext().declareNamespace("xlink", "http://www.w3.org/1999/xlink");
            con.getStaticContext().setDefaultElementTypeNamespace("http://www.xbrl.org/2003/linkbase");
            con.getStaticContext().setDefaultElementTypeNamespace("http://www.w3.org/2001/XMLSchema");

            String queryFile="for $s in fn:doc(\"C:/Users/A/Documents/Sweta/users/sweta231119791251796126671/Other/2008/Quarterly/2nd Quarterly/bvf-20081231/bvf-20081231.xml\")" +
            "//bvf:StockholdersEquityBeforeComprehensiveIncomeNetOfTax, "+
             " $c in fn:doc(\"C:/Users/A/Documents/Sweta/users/sweta231119791251796126671/Other/2008/Quarterly/2nd Quarterly/bvf-20081231/bvf-20081231.xsd\")" +    
             "//element[@name=local-name($s)]  "+
            " return($s, data($c/@name))";
            SaxonXQPreparedExpression expr = (SaxonXQPreparedExpression) con.prepareExpression(queryFile);
        
            SaxonXQForwardSequence rs = (SaxonXQForwardSequence) expr.executeQuery();

            while (rs.next()) {
                SaxonXQItem item = (SaxonXQItem) rs.getItem();
                Location local = item.getItemAsStream().getLocation();
                System.out.println(item.getItemAsString(null).toString() + " at Line: " + local.getLineNumber());
            }

          
            / rs.close();
            con.close();
        }
        catch (javax.xml.xquery.XQException xq) {
            xq.printStackTrace();
            System.out.println(xq.getStackTrace().toString());
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
    }

   
}