Re: [xsl] XPath statement required pls

Subject: Re: [xsl] XPath statement required pls
From: "Sanjay Pandey/Towers Perrin" <pandeys@xxxxxxxxxx>
Date: Mon, 13 Aug 2001 15:20:36 -0400

It works fine till
//theField/ancestor::*[@name]

but, when I try to get the first ancestor:
//theField/ancestor::*[@name][1]
I get java.lang.StackOverflowError

Any suggestions would be appreciated.

Thanks,
Sanjay



                                                                                                                                 
                                                                                                                                 
                                                       To:     xsl-list@xxxxxxxxxxxxxxxxxxxxxx                                   
                    Adam Turoff                        cc:     (bcc: Sanjay Pandey/Towers Perrin)                                
                    <ziggy@xxxxxxxxx>                  Subject:     Re: [xsl] XPath statement required pls                       
                    Sent by:                                                                                                     
                    owner-xsl-list@xxxxxxxxxxxx                                                                                  
                    rytech.com                                                                                                   
                                                                                                                                 
                                                                                                                                 
                    08/13/2001 02:02 PM                                                                                          
                    Please respond to xsl-list                                                                                   
                                                                                                                                 
                                                                                                                                 



On Mon, Aug 13, 2001 at 01:44:04PM -0400, Sanjay Pandey/Towers Perrin
wrote:
>
> Hi,
>
> I have XML file as follows:
> <parameter name = "one">
>    <level1>
>       <level2 name = "a">
>      <level3>
>           <theField>something</theField>
>      </level3>
>       </level2>
>       <level2 name = "b">
>      <level3>
>           <theField>something</theField>
>      </level3>
>       </level2>
>       <level2 name = "c">
>      <level3>
>           <theField>something</theField>
>      </level3>
>       </level2>
>    </level1>
> </parameter>
>
> <parameter name = "two">
> </parameter>
>
> My problem is as follows:
> 1. I need to get all the occurrances of <theField> (... and that is fine,
I
> am getting those, using XPathAPI, into a NodeIterator)

//theField

Find all occurances of <theField>.

> 2. For each field I want to get the nearest Attribute value, so that I
can
> uniquely identify <theField>. Is there a generic way to get the
>      nearest Attribute value? In my case it is not always true that the
> attribute for a field (in this case <theField>) is at a particular level
>      (in the current case, I can get the attribute value by going 2
levels
> up, ... but then that is what I am trying to find if there is generic
>       way to find the nearest Attribute value for a particular field)

//theField/ancestor::*[@name][1]/@name

Find all occurrances of <theField>, then the first ancestor with a name
attribute, then that name attribute.

HTH,

Z.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread