[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: Eric Smith <Eric.Smith@xxxxxxxxxxxx>
Date: Mon, 15 Apr 2002 23:44:11 +0200
executing xsl ie
According to Michael Kay on Mon, Apr 15, 2002 at 08:04:43PM +0100:
> You can't add attributes to an element after adding a text node. This is so
> that XSLT processors are able to operate serially.
> 
> What you are trying to do is effectively:
> 
> <xsl:element name="e">
>   text
>   <xsl:attribute name="a">5</xsl:attribute>
> </xsl:element>
> 
> A processor trying to output
> <e a="5">text</e>
> 
> would have to delay outputting the "text" until it was sure there were no
> attributes to be added.
> 

Thanks Michael, but please bear with me and take-5.  The text
node is a complete red herring - I don't need or want it.

Use case is:
I want to call a single function from various templates that will
allow me to add various attributes to the source document and
have these out put in xsl:fo.  Things like font-size and
text-alignment etc.  I would think this quite a common requirement.

The solution I suggested (but may be entirely inappropriate)
partly works in that it will output a text node but not an xsl
instruction i.e. one that adds an attribute to the most recently
defined node.  So taking away the red herring:



<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">
      <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>
<!-- highly dubious statement follows
which should add an attribute if it finds
an attribute in the source matching one of
the conditions in the attributes template.  -->

<xsl:value-of select="$y"/>

<!-- I cannot immediately figure how xsl:element helps here. -->

Thanx
-- 
Eric Smith 

 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.