xsl-list
[Top] [All Lists]

switching designs in xsl

2003-12-15 07:59:58
Hi,

I do some xsl:fo formatting that depends on the value of an element <design-id 
value="design-001" />. I keep the xsl stylesheets for each design in a separate 
directory 'design-001'. Currently, I import all designs in my start xsl and 
then switch according to the value of the design-id. This works but has the 
disadvantage that all templates, attribute-sets etc have to be globally 
distinct, which I do by prefixing them with a 
design-marker, e.g. 'd001-'. This strikes me as not very elegant. What would be 
a more clever way to do this? I append my top stylesheet, to give people an 
idea what I am doing.

Thanks for your help.

Erwin


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:fo="http://www.w3.org/1999/XSL/Format";>

  <xsl:include href="design-001/d001-format-complete.xsl" />
  <xsl:include href="design-002/d002-format-complete.xsl" />

  <xsl:template match="/">
    <xsl:variable name="design-id" select="/printobject/design-id/@value"/>
    <xsl:choose>
      <xsl:when test="$design-id = 'design-001'">
         <xsl:call-template name="d001-format-complete"/>
      </xsl:when>
      <xsl:when test="$design-id = 'design-002'">
        <xsl:call-template name="d002-format-complete"/>
      </xsl:when>
    </xsl:choose>   
  </xsl:template>
</xsl:stylesheet>



..............................

Erwin Kloeck
Produktentwicklung

Oestreicher + Wagner 
Medientechnik GmbH
Frankenthaler Strasse 20
D-81539 Muenchen

Fon   +49 (0)89-68961 216 
Fax   +49 (0)89-68961 271


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



<Prev in Thread] Current Thread [Next in Thread>