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: How to embed xsl:value-of into html tag


Chris,

Since Jeni already snagged this one, I don't have to. (Thanks J.!)

The key thing is to keep in mind that how an expression will evaluate
depends partly on the context node -- but that /hitlist/patn, for example,
evaluates from the root and always returns the same node set (whose value
is the value of the first node in it). Jeni's point that in a given context
you should use the same XPath expression to get the same results, is good
advice in general: understanding this it makes it all easier.

XSLT is wonderfully useful even if you don't fathom the mysteries of XPath
(and patterns, and one or two other arcana I won't mention), but it doesn't
really 'click' until you do.

Enjoy,
Wendell

At 09:53 AM 8/25/00 +0100, you wrote:
>Chris,
>
>>When I use the AVT, it won't advance past my fisrt URL, but I use a value
>>of select for what is displayed on the screen and that advances fine:
>
>Presumably this is inside a template matching 'patn' or a xsl:for-each
>iterating over them, e.g.:
>
><xsl:template match="patn">
> <A HREF="/details?pn={/hitlist/patn}"><xsl:value-of select="." /></A>
></xsl:template>
>
>Look at the XPaths you're using.  To get the content of the link, you're
>using a '.', which means 'get the string value of the current node'.  In
>the AVT, you're using '/hitlist/patn', which means 'get the string value of
>the 'patn' child(ren) of the 'hitlist' document element'.
>
>/hitlist/patn will always give you all the 'patn' children of the 'hitlist'
>element.  Node lists are converted into strings by taking the string value
>of the first node in the node list - in this case the first 'patn' element
>('1').  So you always get the same answer.
>
>What you wanted was the string-value of the current 'patn' element -
>exactly the same as you're using as the content of the link itself:
>
><xsl:template match="patn">
> <A HREF="/details?pn={.}"><xsl:value-of select="." /></A>
></xsl:template>
>
>It's odd that you managed to get the right value for the xsl:value-of but
>not the AVT.  AVTs work in exactly the same way as the 'select' expression
>of xsl:value-of - if you want the same value, use the same XPath! ;)
>
>I hope that clears things up,
>
>Jeni


======================================================================
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]