Thanks Michael,

It worked :)



On Mon, Apr 5, 2010 at 1:21 PM, Michael Kay <mike@saxonica.com> wrote:
Try
 
if (node.iterateAxis(Axis.CHILD, NodeKindTest.ELEMENT).next() != null)

From: Geet Gangwar [mailto:geetgangwar@gmail.com]
Sent: 05 April 2010 08:27

To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] NodeInfo object returning null for getAttributeValuemethod

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.


Regards

Geet

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
 
node.iterateAxis(Axis.ATTRIBUTE)
 
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.
 


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.

Regards

Geet.

------------------------------------------------------------------------------
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.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
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.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help