Re: [xsl] Setting a foreign attribute

Subject: Re: [xsl] Setting a foreign attribute
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sat, 31 Oct 2009 17:22:42 -0400
At 2009-10-31 14:15 -0700, Mark Wilson wrote:
FOP does not like this fragment and calls <xsl:use-attribute-sets> a foreign attribute.

Right ... xsl:use-attribute-sets= is recognized by XSLT processors and you are putting that attribute into an XSL-FO file which doesn't recognize it because it isn't part of the FO vocabulary so FO processors rightfully complain.


<fo:block>
<xsl:choose>
<xsl:when test="parent::Item">
<xsl:attribute name=" xsl:use-attribute-sets">article0</xsl:attribute>
</xsl:when>
<xsl:when test="parent::Level1">
<xsl:attribute name=" xsl:use-attribute-sets">article1</xsl:attribute>
</xsl:when>
<xsl:when test="parent::Level2">
<xsl:attribute name=" xsl:use-attribute-sets">article2</xsl:attribute>
</xsl:when>
<xsl:when test="parent::Level3">
<xsl:attribute name=" xsl:use-attribute-sets">article3</xsl:attribute>
</xsl:when>
</xsl:choose>


                                   .....
                       </fo:block>

Is there a way to set <xsl:attribute-sets> similar to my unacceptable construction, or do I have to create all six attributes for each <xsl:when>?

The latter. You've overlooked what is happening where in the process. xsl:use-attribute-sets= is acted on during the building of the result tree and isn't recognized when placed directly in the result tree.


If you change:

  <xsl:attribute-set name="article0">
    ...
  </xsl:attribute-set>

to:

  <xsl:template name="article0">
    ...
  </xsl:template>

Then you can use <xsl:call-template name='article0'/> in order to add all of the attributes, but it means that everywhere where you have:

  <fo:block xsl:use-attribute-sets="article0">
    ...

you will need to have:

  <fo:block>
    <xsl:call-template name='article0'/>
    ...

But there are features of xsl:use-attribute-sets= that might mean you can't just do that everywhere.

I hope this helps.

. . . . . . . . . . Ken

--
Upcoming:  hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009
Interested in other classes?  http://www.CraneSoftwrights.com/s/i/
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@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread