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

Re: backtracking and trying to find a sub-node

Subject: Re: backtracking and trying to find a sub-node
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 21 Nov 2000 17:24:48 +0000
attribute xslt
Hi Rob,

<xsl:variable name="images" select="ancestor::section//image"/>
   <xsl:variable name="image.hd1" select="$images[@role='hd1']"/>
   <xsl:variable name="image.hd2" select="$images[@role='hd2']"/>

Just glancing at it, this code looks okay. The values of that 'role' attribute are unique, I take it (or you'd be getting a node set containing more than one node for each of the image.hd1 and image.hd2 attributes).


   &lt;image src="<xsl:value-of select="$image.hd1/@fileref"/>"
width="<xsl:value-of select="$image.hd1/@width"/>" height="<xsl:value-of
select="$image.hd1/@height"/>" /&gt;

  &lt;image src="<xsl:value-of select="$image.hd2/@fileref"/>"
width="<xsl:value-of select="$image.hd2/@width"/>" height="<xsl:value-of
select="$image.hd2/@height"/>" /&gt;
</xsl:template>

The reason this looks so monstrous is that XSLT wasn't designed to work this way. Try something more like:


 <image src="{$image.hd1/@fileref}"
      width="{$image.hd1/@width}"
     height="{$image.hd1/@height}"/>

and you'll be much happier. The { } construction is an attribute value template (XSLT 7.6.2), designed for exactly this use case (evaluating expressions to appear in attribute values in literal result elements). How to do this is, actually, a FAQ.

I'm not sure this answers exactly the question you asked; but maybe it'll clear things up enough to clarify (please feel free to ask again if not).

Good luck,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx 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



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.