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

Subject: Re: [xsl] call-template and execute xsl command
From: "David N Bertoni/Cambridge/IBM" <david_n_bertoni@xxxxxxxxxx>
Date: Mon, 15 Apr 2002 11:33:06 -0700
Eric Smith wrote:
>
> Hi
>
> I have a named template of the following form:
>
>
> <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.

The literal text in your template adds a text node to element being
generated in the result tree.  Once a child has been added, you can no
longer add attributes.  Your processor can:

   1. signal an error, and quit.
   2. warn you, and recover by not adding the attribute.
   3. Silently recover by not adding the attribute.

See:

   http://www.w3.org/TR/xslt#creating-attributes

You could put the literal text _after_ the xsl:attribute instruction, but
placing debugging text in a template that generates attributes is probably
not a good idea.  You might try xsl:message, if your processor supports
emitting the message to the console.

Dave



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread