472,125 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,125 software developers and data experts.

Using value-of within double quotes??

Hi,

I have a an XML file:

<xml...
<store>
<book>
<title>Darkness at Noon</title>
<price>12.99</price>
<url>http://www.amazon.com/...</url>
</book>
Mar 1 '07 #1
4 3862
Figured it out (eventually)

<xsl:for-each select="store/book">
<p><strong><value-of select="title" /></strong></p>
<p>&pound;<value-of select="price" /></p>
<p><a href="{url}">Buy book</a></p>
</xsl:for-each>
or use xsl:attribute but havent yet tried that one.

Mar 1 '07 #2
bi******@yahoo.co.uk wrote:
<p><a href="{url}">Buy book</a></p>
Yep; that's known as an Attribute Value Template (AVT), and is the
simplest way to generate an attribute with a known name.
or use xsl:attribute but havent yet tried that one.
More often used when you need to programmatically generate the
attribute's name, or when you need fancier logic in setting its value
than an AVT can support:

<p><a><xsl:attribute name="href" select="url"/>Buy book</a></p>
or

<p><a><xsl:attribute name="href"><xsl:value-of
select="url"/></xsl:attribute>Buy book</a></p>

or, for stylesheet readability reasons:
<p><a>
<xsl:attribute name="href"/>
<xsl:value-of select="url"/>
</xsl:attribute>
<xsl:text>Buy book</xsl:text>
</a></p>

.... or any of the equivalents thereof. (XSLT being a programming
language, there is usually more than one way to achieve a given result.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 1 '07 #3
Joe Kesselman wrote:
More often used when you need to programmatically generate the
attribute's name, or when you need fancier logic in setting its value
than an AVT can support:

<p><a><xsl:attribute name="href" select="url"/>Buy book</a></p>
But xsl:attribute in XSLT 1.0 does not have a select attribute
<http://www.w3.org/TR/xslt#creating-attributes>
it is a bit dangerous to show that example above without mentioning it
is only supported in XSLT 2.0
<http://www.w3.org/TR/xslt20/#creating-attributes>


--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 1 '07 #4
Martin Honnen wrote:
But xsl:attribute in XSLT 1.0 does not have a select attribute
Whups. You're right, very sloppy of me. I did illustrate the
value-as-content solution as well; that does work in 1.0.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Mar 1 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by cover | last post: by
1 post views Thread by ansc1 | last post: by
2 posts views Thread by =?Utf-8?B?VmljdG9yIExhaQ==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.