xsl-list
[Top] [All Lists]

Re: [xsl] To self or not to self

2012-01-27 09:22:20
ihe onwuka wrote:
I wanted to isolate the figure element that has a figure as an
immediate preceding sibling.

        <section role="All_models">
             <title>All models</title>
             <figure role="Harness_multi-plug">
                 <title>ECU harness multi-plug</title>
                 <mediaobject>
                     <imageobject>
                         <imagedata fileref="78650"/>
                     </imageobject>
                 </mediaobject>
             </figure>
             <figure role="Circuit_diagram">
                 <title>System circuit diagram</title>
                 <mediaobject>
                     <imageobject>
                         <imagedata fileref="31544"/>
                     </imageobject>
                 </mediaobject>
             </figure>
         </section>

I settled on //figure/preceding-sibling::*[1][figure] but it gave back
nothing and would only work when I used the explicit form of the self
axis.

Well [figure] checks wether there is a child element named figure, not whether the element itself is a figure element.

I settled on //figure/preceding-sibling::*[1][self::figure]

However if I want the title element immediately preceding figure I
don't need to use the explicit form. This works

//figure/preceding-sibling::*[1][title]

So what is going on in this particular case (because I don't
understand the difference), and in general when is explicit self
required.

The same here, [title] checks whether there is a child element named "title", only in your XML that is the case.


--

        Martin Honnen --- MVP Data Platform Development
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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