[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Conditionally use attribute sets?

Subject: Re: Conditionally use attribute sets?
From: JBryant@xxxxxxxxx
Date: Mon, 14 Nov 2005 10:11:15 -0600
fop use attribute sets
It can be done. Consider the following stylesheet (which you can test by 
applying it to itself):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="xml" version="2.0" omit-xml-declaration="no" 
indent="yes"/>

  <xsl:param name="who"/>

  <xsl:attribute-set name="Oscar">
    <xsl:attribute name="slob">yes</xsl:attribute>
  </xsl:attribute-set>

  <xsl:attribute-set name="Felix">
    <xsl:attribute name="slob">no</xsl:attribute>
  </xsl:attribute-set>

  <xsl:template match="/">
    <bachelor>
      <xsl:choose>
        <xsl:when test="$who='Oscar'">
          <xsl:attribute name="xsl:use-attribute-sets">
            <xsl:value-of select="'Oscar'"/>
          </xsl:attribute>
        </xsl:when>
        <xsl:when test="$who='Felix'">
          <xsl:attribute name="xsl:use-attribute-sets">
            <xsl:value-of select="'Felix'"/>
          </xsl:attribute>
        </xsl:when>
      </xsl:choose>
    </bachelor>
  </xsl:template>

</xsl:stylesheet>

I tested that with Xalan Java 2.4.1

It's easier in 2.0 because 

<xsl:attribute name="xsl:use-attribute-sets">
  <xsl:value-of select="'Oscar'"/>
</xsl:attribute>

can be

<xsl:attribute name="xsl:use-attribute-sets" select="'Oscar'"/>

I tested that with Saxon 8.5.1.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

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.