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

RE: accessing individual nodes while iterating

Subject: RE: accessing individual nodes while iterating
From: "Martinez, Brian" <brian.martinez@xxxxxxxx>
Date: Thu, 12 Dec 2002 15:05:15 -0700
xslt iterating attributes names
> From: NIENKE, Bill P. - ACCOR-NA [mailto:Nienke_Bill@xxxxxxxxxxxx]
> Sent: Thursday, December 12, 2002 2:36 PM
> Subject:  accessing individual nodes while iterating
> 
> 
> Hi,
> I'm having troubles translating XML into HTML. I can iterate 
> through the WPT
> nodes, but I get all of the child nodes too. Since I don't 
> want all of the
> nodes in my output I'd like to format like this:
> <a 
> href="http://www.geocaching.com/seek/cache_details.aspx?ID=38989">Hunt
> for the Hideout by Nick & Nora</a> - GC984D

You didn't provide your current XSLT code, but I'm guessing that you're
using xsl:copy-of instead of xsl:value-of.  copy-of will do a deep copy of
the node (attributes and child nodes included).  value-of copies the string
value of the select expression.  The following does what you want:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
	
  <xsl:template match="/">
    <xsl:for-each select="wpt">
	<a>
	  <xsl:attribute name="href"><xsl:value-of
select="url"/></xsl:attribute>
	  <xsl:value-of select="desc"/>
	</a> - <xsl:value-of select="name"/><br/>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

> Also, how would I work an xsl:sort into the iteration?

xsl:sort must appear before the template body in a for-each iteration:

<xsl:for-each select="wpt">
  <xsl:sort select="desc"/>
  etc.
</xsl:for-each>

hth,
b.

| brian martinez                              brian.martinez@xxxxxxxx |
| senior gui programmer                                  303.708.7248 |
| trip network, inc.                                 fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| http://www.cheaptickets.com/                   http://www.trip.com/ |

 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.