This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: call-template and execute xsl command


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]