xsl-list
[Top] [All Lists]

selecting the nearest preceding sibling

2003-05-13 05:43:26
Hello ,
My XML file is below

XML file
------------
<rootelem>

<tag> --- node 1
<a>1</a>
<b>2</b>
<c>3</c>
<d>4</d>
</tag>

<tag>  --- node 2
<b>5</b>
<c>6</c>
<d>7</d>
</tag>

<tag>  --- node 3
<a>8</a>
<b>9</b>
<c>10</c>
<d>11</d>
</tag>

<tag>   --- node 4
<b>12</b>
<c>13</c>
<d>14</d>
</tag>

<tag>   --- node 5
<b>15</b>
<c>16</c>
<d>17</d>
</tag>

</rootelem>
----------------------
I want to write **a XPATH expression which will select
the nearest preceding sibling , which contains a
particular element ( <a> in this example) ** . I do
not want preceding sibling which do not contain the
<a> tag (also the tag <a> should be nearest to the
context node)

for e.g. if the context node is node 5 , the XPATH
expression which will select node 3(because it
contains element <a>) or for e.g. if the context node
is node 2 , the XPATH expression will select node
1(because it contains element <a>)

I am trying with preceding-sibling::tag ?? 

Can somebody suggest a solution?

Regards,
Mukul




__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

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



<Prev in Thread] Current Thread [Next in Thread>