Altova Mailing List Archives

Re: [xsl] call-template and execute xsl command

From: Greg Faron <gfaron@------------------>
Date: 4/15/2002 10:14:00 AM
At 11:26 AM 4/15/2002, you wrote:
<xsl:template name= "attributes">


     <xsl:when test="@font-size">

      <xsl:attribute name="font-size"><xsl:value-of 


     <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 




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

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, <>, 
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:


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'/>



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:


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.