xsl-list
[Top] [All Lists]

Re: how can I get the attribute?

2002-10-22 06:56:02
<xsl:value-of select="../../yacht/@yachtid"/>

or with complete axes for maybe better understanding:

<xsl:value-of select="parent::route/parent::cruise/child::yacht/attribute::yachtid"/>

another possibility:

<xsl:value-of select="parent::route/preceding-sibling::yacht/attribute::yachtid"/>

or back to the short way:

<xsl:value-of select="../preceding-sibling::yacht/@yachtid"/>

Regards,

Joerg

Peter Lavender wrote:
Hi Everyone,

I'm tring to get the xpath right to grab the yachtid attribute from a
template.. here is the structure of the document:

<cruise_doc>
<cruise cruiseid='5152' status='available'>
<!-- Comment for Cruise 5152 --> <price>761</price>
        <description>Any text describing this cruise
5152</description>
        <yacht yachtid='154'/>
        <route>
               <date>2002-07-17</date>
               <harbor>ZAKYNTHOS</harbor>
               <date>2002-07-20</date>
               <harbor>AGIA GALINI</harbor>
               <date>2002-07-25</date>
               <harbor>SANTORINI</harbor>
               <date>2002-07-30</date>
               <harbor>ATHEN</harbor>
               <image file='route.gif'/>
        </route>
        <skipper>
               <!-- Comment for Processing Instruction pinst1 -->
               <?pinst1 now='stop'?>
               <name>WATTS,JOSEPH</name>
               <address>
                     <zip>DE1 2KL</zip>
                     <city>DERBY</city>
                     <street>3 SADLER GATE</street>
               </address>
               <image file='skipper.gif'/>
               <description>Any text describing this skipper
WATTS</description>
        </skipper>
</cruise>
</cruise_doc>

And here is my template:

    <xsl:template name="passLocation">
        <xsl:param name="passes" select="AZOREN"/>
        <h2>Cruise(s) that pass <xsl:value-of select="$passes"/></h2>
<xsl:for-each select="/cruise_doc/cruise/route/harbor">
            <xsl:if test=". = $passes">
                <br/><b>Yacht ID:</b> <xsl:value-of
select="../../self::yacht[(_at_)yachtid]"/>
                <br/><b>Cruise:</b> <xsl:value-of
select="../../@cruiseid"/>
                <br/><b>Starting Point:</b><xsl:text> </xsl:text>
<xsl:value-of select="../harbor[1]"/>
                <br/><b>Ending Point:</b><xsl:text> </xsl:text>
<xsl:value-of select="../harbor[last()]"/><br/>
            </xsl:if>
        </xsl:for-each>
    </xsl:template>


Each bit EXCEPT where I try to get the attribute works...

I'm at a loss... the combinations I have tried are numerous, and
probably amazingly bad.. :)


br/><b>Yacht ID:</b> <xsl:value-of select="../../self::yacht[(_at_)yachtid]"/>



THanks...


Regards,

Pete.



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



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