[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Best practice for "walking" node

Subject: RE: Best practice for "walking" node
From: "Lopez, William" <william.lopez@xxxxxxx>
Date: Wed, 8 Jan 2003 08:11:31 -0600
xsl accessing element attributes
Thanks Andrew for the explanation.

-----Original Message-----
From: Andrew Welch [mailto:AWelch@xxxxxxxxxxxxxxx]
Sent: Wednesday, January 08, 2003 3:43 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Best practice for "walking" node



> <xsl:value-of
> select="./following-sibling::WorkGroupCollection/WorkGroup/@name"/>
> 
> <xsl:value-of select="./following::WorkGroup/@name"/> <-- I 
> like this one
> because it is shorter

The following-sibling axis will select nodes after the current node in
document order that have the same parent, whereas the following will select
*all* nodes after the current node in document order, regardless of parent.
Therefore it depends on what you are trying to achieve, you can't really
compare the two on performance.

cheers
andrew

> -----Original Message-----
> From: Lopez, William [mailto:william.lopez@xxxxxxx]
> Sent: 07 January 2003 23:14
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Best practice for "walking" node
> 
> 
> Sorry if this is trivial...I was wondering which way is best to access
> elements/attributes. I was playing around with the axis 
> (pardon if the lingo
> is bogus) way of accessing elements/attributes and found the 
> following ways
> work but is there an advantage of using one over the other 
> (besides brevity
> of code). See 1. & 2. below.
> 
> <xsl:value-of
> select="./following-sibling::WorkGroupCollection/WorkGroup/@name"/>
> 
> <xsl:value-of select="./following::WorkGroup/@name"/> <-- I 
> like this one
> because it is shorter
> 
> *** xml document ***
> <WorkGroupMaint>
>   <BusinessUnitRef oid="0:0:0:1" name="BU01">  <-- 1. 
> processor is here
>     <TeamRef oid="0:0:1:1" name="TM01"/>
>   </BusinessUnitRef>
>   <WorkGroupCollection nbrWorkGroup="1">
>     <WorkGroup oid="0:0:0:2" name="WorkGroup 1"> <-- 2. I need @name
>       <WorkTypeCollection nbrWorkType="2">
> ...
> </WorkGroupMaint>
> 
>  *** xsl template ***
> <xsl:template match="BusinessUnitRef">
>         <p id="topLabel">
>           <span class="info">Team: <xsl:value-of
> select="TeamRef/@name"/></span><br/>
>           <span class="info">Business Unit: <xsl:value-of
> select="@name"/></span><br/>
> 	    <xsl:choose>
>             <xsl:when test="$entryMode = 'Add'">
>              <span class="info">Work Group Name: </span>
> 		 <input type="text" name="txtWorkGroupName" class="info"
> value="" size="30"/>
>             </xsl:when>
> 		<xsl:otherwise>
> 		 <span class="info">Work Group Name: <xsl:value-of
> select="./following::WorkGroup/@name"/></span>
> 		</xsl:otherwise>
> 	    </xsl:choose>
>         </p>
> </xsl:template>
> 
> Thanks,
> -Will
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
>  
> 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.427 / Virus Database: 240 - Release Date: 06/12/2002
 

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

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.