Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Conditional xsl:use-attribute-sets

From: "G. Ken Holman" <gkholman@----------------.--->
To: xsl-list@-----.------------.---
Date: 6/1/2009 7:45:00 PM
At 2009-06-01 12:37 -0700, Karl Stubsjoen wrote:
>Am I doing something wrong because this is not working:
>
>         <fo:table-row hyphenate="true">
>             <xsl:if test="position() mod 2 = 0">
>                 <xsl:attribute
>name="xsl:use-attribute-sets">background-gray</xsl:attribute>
>             </xsl:if>
>
>Is that the correct way to call an attribute set conditionally?

Unfortunately, attribute sets cannot be added conditionally.  I've 
wanted to do this myself in the past.

If you change the attribute set to a called template (no other 
changes), then you can put the call to the template in the if.

Doing so takes away the cumulative nature of attribute sets in an 
import/include tree, but if that isn't a concern for you, then a 
called template should do the trick.

So, change:

   <xsl:attribute-set name="my:background-gray">
     <xsl:attribute name="background-color">#dddddd</
     <xsl:attribute name="border">#222222</
   </xsl:attribute-set>

to:

   <xsl:template name="my:background-gray">
     <xsl:attribute name="background-color">#dddddd</
     <xsl:attribute name="border">#222222</
   </xsl:template>

and use:

    <fo:table-row hyphenate="true">
       <xsl:if test="position() mod 2 = 0">
         <xsl:call-template name="my-background-gray"/>
       </xsl:if>
    ....

I hope this helps.

. . . . . . . . . . . . . Ken


--
XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@C...
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

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 www.altova.com/list/index.html. 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.

.
.

transparent

transparent