RE: [xsl] How to get innermost ancestor

Subject: RE: [xsl] How to get innermost ancestor
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 24 Jul 2006 09:11:22 +0100
The innermost ancestor of an element that has an attribute @userlevel is
given by the expression

ancestor::*[@userlevel][1]

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: J. S. Rawat [mailto:jrawat@xxxxxxxxxxxxx] 
> Sent: 24 July 2006 06:52
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] How to get innermost ancestor
> 
> Could anyone please let me know that how could I get the 
> innermost ancestor of "imagedata" by xslt. If I want most 
> inner ancestor of <imagedata fileref="abc.tif"/> having 
> attribute "userlevel" than it should return
> "<sec2 userlevel="4.1.2.1"> not "<chapter userlevel="3.1.2">.
> 
> thanks
> ...JSR
> 
> Source XML
> <chapter userlevel="3:1.2">
> <title>Structuring learning</title>
> <sect1>
> <title>Introduction</title>
> <sect2 userlevel="4:1.2.1">
> <title>Common issues</title>
> <para>...</para>
> <mediaobject>
> <imageobject>
> <imagedata fileref="abc.tif" format="TIFF"/> </imageobject> 
> </mediaobject>
> <sect3 userlevel="5:1.2.1">
> <title>Common issues</title>
> <para>...</para>
> <mediaobject>
> <imageobject>
> <imagedata fileref="abc1.tif" format="TIFF"/> </imageobject> 
> </mediaobject> </sect3> </sect2> </sect1> </chapter>

Current Thread