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

Re: call-template and execute xsl command

Subject: Re: call-template and execute xsl command
From: Greg Faron <gfaron@xxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Apr 2002 12:18:08 -0600
eric asp execute net
At 11:26 AM 4/15/2002, you wrote:
<xsl:template name= "attributes">
<xsl:choose>
<xsl:when test="@font-size">
<xsl:attribute name="font-size"><xsl:value-of select="@font-size"/></xsl:attribute>
</xsl:when>
<xsl:when test="@text-align">
This text prints out if @text-align but the xsl:command is not executed
<xsl:attribute name="text-align"><xsl:value-of select="@text-align"/></xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:template>


called like this:
 <xsl:variable name='y'>
   <xsl:call-template name='attributes'/>
 </xsl:variable>

However, as you may see by my notes above, text prints out fine
subject to the condition, however I cannot change or add
attributes as required.

According to one site, <http://www.topxml.com/xsl/elmxsl_attribute.asp>, the xsl:attribute element may be contained within a xsl:when element, so your stylesheet is technically valid. But, I believe you're using a loophole in that it really must be used within a xsl:element element. Here's a quote from the site:


Element:xsl:attribute
Generates an attribute in the destination document. It should be used in the context of an element (either a literal, xsl:element or some other element that generates an element in the output). It must occur before any text or element content is generated.


As a minimum-effort suggestion, I recommend modifying your variable to be like this:
<xsl:variable name='y'>
<xsl:element name="'something'">
<xsl:call-template name='attributes'/>
</xsl:element>
</xsl:variable>


although I suspect a more hefty re-work may be necessary. Your variable will probably not be a true node, so will have to be converted to a node-set using an extension function. After this conversion, you'll likely want the first child of the new set.
<xsl:variable "y2" select="msxsl:node-set($y)"/>
<xsl:variable "y3" select="$y2/*[1]"/>



Greg Faron Integre Technical Publishing Co.



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.