This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: backtracking and trying to find a sub-node


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@mulberrytech.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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]