?
=?iso-8859-1?q?Jean-Fran=E7ois_Michaud?=
Hello guys,
I was wondering if it was possible to reference a boolean predicate in
a variable. Basically I want to do with the boolean predicate what you
would do with any other variable; I want it to apply to many places
without having to update all those different locations if the
predicate needs to change.
This is not a full stylesheet, just snippets of the idea
<xsl:variable name="list-orphans-widows.properties">
position()=last()-1 or position()=last()-2 or (position()='1' and
position()!=last()) or (position()='2' and position()!=last())
</xsl:variable>
<xsl:template match="ListB | CELLListB">
<fo:list-block padding-after="12pt">
<xsl:variable name="ListBItemsRTF">
<ListB>
<xsl:copy-of select="@*"/>
<xsl:for-each select="ListBItem | CELLListB">
<xsl:choose>
<xsl:when test="$list-orphans-widows.properties">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="keep-with-next">always</
xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:when>
<xsltherwise>
<xsl:copy-of select="."/>
</xsltherwise>
</xsl:choose>
</xsl:for-each>
</ListB>
</xsl:variable>
<xsl:for-each select="exsl:node-set($ListBItemsRTF)">
<xsl:apply-templates select="//ListBItem | //CELLListBItem"/>
</xsl:for-each>
</fo:list-block>
</xsl:template>
It works cleanly when the predicate is straight up in test="", but the
predicate yields true in all cases when I try to reference the
variable. Is what I'm trying to do possible in XSLT?
Regards
Jean-Francois Michaud
I was wondering if it was possible to reference a boolean predicate in
a variable. Basically I want to do with the boolean predicate what you
would do with any other variable; I want it to apply to many places
without having to update all those different locations if the
predicate needs to change.
This is not a full stylesheet, just snippets of the idea
<xsl:variable name="list-orphans-widows.properties">
position()=last()-1 or position()=last()-2 or (position()='1' and
position()!=last()) or (position()='2' and position()!=last())
</xsl:variable>
<xsl:template match="ListB | CELLListB">
<fo:list-block padding-after="12pt">
<xsl:variable name="ListBItemsRTF">
<ListB>
<xsl:copy-of select="@*"/>
<xsl:for-each select="ListBItem | CELLListB">
<xsl:choose>
<xsl:when test="$list-orphans-widows.properties">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="keep-with-next">always</
xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:when>
<xsltherwise>
<xsl:copy-of select="."/>
</xsltherwise>
</xsl:choose>
</xsl:for-each>
</ListB>
</xsl:variable>
<xsl:for-each select="exsl:node-set($ListBItemsRTF)">
<xsl:apply-templates select="//ListBItem | //CELLListBItem"/>
</xsl:for-each>
</fo:list-block>
</xsl:template>
It works cleanly when the predicate is straight up in test="", but the
predicate yields true in all cases when I try to reference the
variable. Is what I'm trying to do possible in XSLT?
Regards
Jean-Francois Michaud