XQJ doesn't give you much help with this - the only mechanism it provides is to convert the node to a DOM node, which can be rather expensive.
But once you've got a Saxon NodeInfo (which you seem to have achieved successfully), the simplest way to get an attribute value is probably to use the helper method in net.sf.saxon.om.Navigator:
Navigator.getAttributeValue(element, uri, localName)
If you want to iterate over all the attributes without knowing their names, use
You can find the line number of an element using node.getLineNumber(), provided line numbers were maintained when building the tree. Line numbers for individual attributes are not maintained.


Michael Kay

From: Geet Gangwar [mailto:geetgangwar@gmail.com]
Sent: 30 March 2010 10:44
To: saxon-help@lists.sourceforge.net
Subject: [saxon] NodeInfo object returning null for getAttributeValue method

Can anybody tell me how can I get the attributes of the node returned.

I have an xml file which contains node named

 <link:schemaRef xlink:type="simple" xlink:href="bvf-20081231.xsd" />
  <link:schemaRef xlink:href="bvf1111-20081231.xsd" xlink:type="tuple"/>

Now i have written a xQuery which return me both the nodes, code is mentioned below:

XQResultSequence xqs = xqe.executeQuery("for $x in /xbrli:xbrl/link:schemaRef return $x");
            SchemaRef objSchemaRef = new SchemaRef();
            SaxonXQItem item = null;
            while (xqs.next()) {
                item = (SaxonXQItem) xqs.getItem();
                if (item.getSaxonItem() instanceof NodeInfo) {
                    NodeInfo node = (NodeInfo) item.getSaxonItem();

How can I get the attributes of the node, even I want to fetch the line numbers also.