Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2006, 03:14 PM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default <xsl:attribute> vs {}

Hi, I use xslt to transform xml to html and I was wondering if there's any significant difference between using the <xsl:attribute> element like this:
Code:
<a>
<xsl:attribute name="href">
<xsl:value-of .../>
</xsl:attribute>
Click here
</a>
as oppossed to declaring a variable and using it like this:

Code:
<xsl:variable name="url" select=.../>
<a href={$url}>
Click here
</a>
Thanks a lot.

 
Old April 6th, 2006, 03:30 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In Saxon

<a href="{$url}"/>

and

<xsl:element name="a">
  <xsl:attribute name="href">
    <xsl:value-of select="$url"/>
  </xsl:attribute>
</xsl:element>

compile to exactly the same code.

I can't speak for other products.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
embedded <xsl:element> into <xsl:with-param> petergoodman XSLT 2 July 9th, 2008 06:36 AM
Performance for <xsl:import> and <xsl:include> vikkiefd XSLT 2 April 16th, 2008 08:06 AM
<xsl:for-each> with a variable select="attribute" BeneathClouds XSLT 1 August 1st, 2005 03:36 AM
name attribute for <xsl:element> rushman XSLT 2 June 9th, 2005 09:04 AM
problem using <xsl:attribute> arvin XSLT 2 July 21st, 2003 03:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.