xsl-list
[Top] [All Lists]

[xsl] Optimization issue with includes and attribute-sets

2007-01-29 12:56:06
Greetings!

Using xslt 2.0, xpath 2.0, xsl-fo, saxon8b:

I have a stylesheet that contains all of my attribute sets for a complex
transformation.  The templates are modularized in separate files that
may include the attributes.xsl and one or more of the other templates.
This is causing the attribute set to be applied once for every file that
directly or indirectly references it - sometimes 20 times for a single
block.  While this doesn't cause a problem in the output, it sure is not
optimized. For example, the code below applies each attribute set twice.

I had a similar problem when one of the files contained a named
template.  I had to change the include to import to avoid the duplicate
template error, but that doesn't fix this issue.  What do I need to do
to resolve this, seemingly bizarre, behavior?  

Thanks in advance!
Angela Williams, Developer
The 401(k) Company

<!-- main-junk.xsl -->
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:fo="http://www.w3.org/1999/XSL/Format";     
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
                version="2.0">

  <xsl:include href="junk2.xsl" />
  <xsl:include href="junk3.xsl" />

  <xsl:template match="/">
    <xsl:apply-templates select="*" />
  </xsl:template>
</xsl:stylesheet>


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

  <xsl:include href="attributes.xsl" />

  <xsl:template match="test">
    <fo:block xsl:use-attribute-sets="test">
        Test: <xsl:value-of select="." />
    </fo:block>
  </xsl:template>
</xsl:stylesheet>


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

  <xsl:include href="attributes.xsl" />

  <xsl:template match="text">
    <fo:block xsl:use-attribute-sets="text">
      Text:<xsl:value-of select="." />
    </fo:block>
  </xsl:template>
</xsl:stylesheet>


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

  <xsl:attribute-set name="text">
    <xsl:attribute name="font-weight">bold</xsl:attribute>
    <xsl:attribute name="font-size">16pt</xsl:attribute>
    <xsl:attribute name="font-color">red</xsl:attribute>
  </xsl:attribute-set>
  
  <xsl:attribute-set name="test">
    <xsl:attribute name="font-weight">normal</xsl:attribute>
    <xsl:attribute name="font-size">24pt</xsl:attribute>
    <xsl:attribute name="font-color">blue</xsl:attribute>
    <xsl:attribute name="font-style">italic</xsl:attribute>
  </xsl:attribute-set>
</xsl:stylesheet>


<!-- junk.xml -->
<?xml version="1.0" encoding="UTF-8"?>

<junk>
  <test>Testing it</test>
  <text> This is the text.</text>
</junk>







--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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