Re: [xsl] targeting the 'first' instance of the same element in variable structures

Subject: Re: [xsl] targeting the 'first' instance of the same element in variable structures
From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 2 Jul 2024 10:35:59 -0000
select="(.//head)[1]"

On Tue, 2 Jul 2024 at 11:34, Jean-Paul Rehr rehrjb@xxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Dear XSL list,
>
> I am trying to target a specific <head> which can appear nested within a
> variable number of <div> and  possible <list> elements. In the three
> examples below I have put in red the <head> element I want to target with
> the same XSL template. In my way of thinking, it is always the first
> appearance of <head> no matter how deep or shallow it may be nested. But I
> am having trouble conceiving a path that can take into account the variable
> depth. Any thoughts about how to target this?
>
> Many thanks in advance for any assistance,
> JPR
>
>     <div>
>         <div>
>             <div>
>                   <head>Title</head> <!-- nested in 3 divs -->
>                   <p>some content</p>
>              </div>
>         </div>
>         <div>
>              <head>Title</head>
>               <p>some content</p>
>          </div>
>     </div>
>
>     <div>
>            <div>
>                   <head>Title</head> <!-- nested in 2 divs -->
>                   <p>some content</p>
>             </div>
>             <div>
>                   <head>Title</head>
>                   <p>some content</p>
>            </div>
>    </div>
>
>     <div>
>         <div>
>             <div>
>                  <list>
>                       <head>Title</head> <!-- nested in 3 divs and list
> -->
>                       <item></item>
>                       <item></item>
>                  </list>
>              </div>
>              <div>
>                  <head>Title</head>
>                  <p>some content</p>
>              </div>
>         </div>
>     </div>
>
> I am trying to select the first <head>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/2739265> (by
> email <>)

Current Thread