xsl-list
[Top] [All Lists]

Re: finding next element after

2002-10-02 10:53:42
Hi Nate,

At 01:18 PM 10/2/2002, you wrote:
I got it, but want to make sure that I am not doing
anything too funky here, as this is my first real
foray into using axises.

<xsl:choose>
        <xsl:when test="local-name(parent::node())='Link'">
                <xsl:if
test="local-name(../../following-sibling::node())='Caption'">
                        <Caption>
                                <xsl:attribute name="align">
<xsl:value-of select="'bottom'" />
                                                </xsl:attribute>
                                                <xsl:value-of
select="../../following-sibling::node()" />
                                        </Caption>
                                </xsl:if>
                        </xsl:when>

...

Thoughts? Is there an easier/better way to accomplish
this?

How about:

<xsl:when test="parent::Link">
  <xsl:for-each select="../../following-sibling::Caption">
    <!-- this might better be
         ../../following-sibling::*[1][self::Caption]
         if you want to constrain it to the immediately following sibling;
         in any case if there's no Caption nothing happens, like your test
      -->
    <Caption align="bottom">
        <xsl:value-of select="."/>
       <!-- but you might rather apply templates here -->
     </Caption>
  </xsl:for-each>
</xsl:when>

Don't hesitate to post with questions.

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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



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