[yelp-xsl] mal-if: Use if:if instead of if:when in block context
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp-xsl] mal-if: Use if:if instead of if:when in block context
- Date: Wed, 18 May 2011 16:00:50 +0000 (UTC)
commit 6d7a85388dabe422815c3a44d6c98077cef57bcb
Author: Shaun McCance <shaunm gnome org>
Date: Mon May 2 10:19:20 2011 -0400
mal-if: Use if:if instead of if:when in block context
Allowing if:when to be a block and have special handling
inside if:choose presents problems when allowing block
content in if:choose as a fallback.
xslt/mallard/common/mal-if.xsl | 6 ++++--
xslt/mallard/html/mal2html-block.xsl | 12 ++++++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/xslt/mallard/common/mal-if.xsl b/xslt/mallard/common/mal-if.xsl
index 64efa19..4e229e4 100644
--- a/xslt/mallard/common/mal-if.xsl
+++ b/xslt/mallard/common/mal-if.xsl
@@ -60,14 +60,16 @@ This template tests whether the ${test} is true, evaluating it with
the Mallard conditional functions. The ${test} parameter is expected
to be a valid XPath expression. If not provided, it defaults to the
#{if:test} attribute of ${node}, or the non-namespaced #{test}
-attribute if ${node} is a #{if:when} element.
+attribute if ${node} is an #{if:if} or #{if:when} element.
If ${test} evaluates to #{true}, this template outputs the literal
string #{'true'}. Otherwise, it outputs nothing.
-->
<xsl:template name="mal.if.test">
<xsl:param name="node" select="."/>
- <xsl:param name="test" select="$node/self::if:when/@test | $node[not(self::if:when)]/@if:test"/>
+ <xsl:param name="test" select="$node/self::if:if/@test |
+ $node/self::if:when/@test |
+ $node[not(self::if:when)]/@if:test "/>
<xsl:choose>
<xsl:when test="string($test) = ''">
<xsl:text>true</xsl:text>
diff --git a/xslt/mallard/html/mal2html-block.xsl b/xslt/mallard/html/mal2html-block.xsl
index 1d944fb..b328a99 100644
--- a/xslt/mallard/html/mal2html-block.xsl
+++ b/xslt/mallard/html/mal2html-block.xsl
@@ -481,8 +481,8 @@ in accordance with the Mallard specification on fallback block content.
</xsl:choose>
</xsl:template>
-<!-- = if:when = -->
-<xsl:template mode="mal2html.block.mode" match="if:when">
+<!-- = if:if = -->
+<xsl:template mode="mal2html.block.mode" match="if:if">
<xsl:variable name="if">
<xsl:call-template name="mal.if.test"/>
</xsl:variable>
@@ -491,4 +491,12 @@ in accordance with the Mallard specification on fallback block content.
</xsl:if>
</xsl:template>
+<xsl:template mode="mal2html.block.mode" match="if:when | if:else">
+ <xsl:message>
+ <xsl:text>Conditional element </xsl:text>
+ <xsl:value-of select="local-name(.)"/>
+ <xsl:text> encountered outside of choose</xsl:text>
+ </xsl:message>
+</xsl:template>
+
</xsl:stylesheet>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]