Hi Michael,

Is there any boolean function to check whether a particular NodeInfo has element child node or not.

I have tried node.iterateAxis(Axis.CHILD) which returns an Iterator for text node also. but my requirement is to check first whether a node has any child node or not, So is there any function which can checks for child node and returns true or false.



On Tue, Mar 30, 2010 at 4:14 PM, Michael Kay <mike@saxonica.com> wrote:
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.



Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
saxon-help mailing list archived at http://saxon.markmail.org/