I'm having a problem with two consecutive <xsl:apply-templates> that
both should output <xsl:attribute>. I'm having a feeling that I'm trying
to do a forbidden thing, but I figured I'd turn to the list to be sure.
Im running FOP togheter with Xalan to create PDF:s. So the first step is
the transformation of xml via xslt to xsl:fo then to pdf via FOP.
However, problems occur.
The execution is as follows:
1. A template gets called when an element with a "class" attribute is
the active node.
2. The first apply-templates applies any template that is specific for
elements with that name
3. The second apply-templates applies any template that is specific for
elements with that class name
In point three, the output "Cannot add attribute font-family after child
nodes or before an element is produced. Attribute will be ignored." gets
output at the command line.
I'm aware that all <xsl:attribute> must appear in template data before
any child nodes, but I'd figured that since both <apply-templates> only
outputs <xsl:attribute>, it should work. Well, it seems like it perhaps
doesn't work that way after all.
<!-- The template where the error occurs-->
<xsl:template match="p">
<fo:block>
<!-- First apply works -->
<xsl:apply-templates select="." mode="elementselection"/>
<!-- Second gets it attribute output ignored -->
<xsl:apply-templates select="." mode="classselection"/>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<!-- Attributes for a specific type of element is output -->
<xsl:template match="h1" mode="elementselection">
<xsl:attribute name="font-family">sans-serif</xsl:attribute>
<xsl:attribute name="font-size">20pt</xsl:attribute>
...
</xsl:template>
<!-- Attributes for an element with a specific class is output -->
<xsl:template match="*[(_at_)class = 'leadtext']" mode="classselection">
<xsl:attribute name="border-bottom-color">sans-serif</xsl:attribute>
<xsl:attribute name="border-bottom-width">0.5pt</xsl:attribute>
...
</xsl:template>
Regards Erik Beijnoff
erik(_at_)beijnoff(_dot_)com
erik(_at_)addsystems(_dot_)com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list