summaryrefslogtreecommitdiff
path: root/xslt
diff options
context:
space:
mode:
authorShaun McCance <shaunm@gnome.org>2012-03-06 13:53:57 -0500
committerShaun McCance <shaunm@gnome.org>2012-03-06 13:53:57 -0500
commit81b0d47527816b0d9d4e2908aca7616878e98cad (patch)
tree23b5b43fc1efdad98088b01b71eed53c19e1e9e7 /xslt
parent591350f373281cb818d97de6d64bf51feae380bd (diff)
downloadyelp-tools-81b0d47527816b0d9d4e2908aca7616878e98cad.tar.gz
yelp-check: Adding --strict option to validate
Diffstat (limited to 'xslt')
-rw-r--r--xslt/mal-rng.xsl79
1 files changed, 44 insertions, 35 deletions
diff --git a/xslt/mal-rng.xsl b/xslt/mal-rng.xsl
index e80e44c..6049dcd 100644
--- a/xslt/mal-rng.xsl
+++ b/xslt/mal-rng.xsl
@@ -8,6 +8,8 @@
exclude-result-prefixes="mal str exsl rng"
version="1.0">
+<xsl:param name="rng.strict" select="false()"/>
+
<xsl:template match="/*">
<xsl:variable name="version">
<xsl:choose>
@@ -80,41 +82,48 @@
<xsl:param name="first"/>
<xsl:param name="ns"/>
<xsl:param name="nss"/>
- <xsl:variable name="nsmunge" select="self::rng:element or self::rng:attribute"/>
- <xsl:copy>
- <xsl:for-each select="@*">
- <xsl:choose>
- <xsl:when test="$nsmunge and local-name(.) = 'name' and contains(., ':')">
- <xsl:attribute name="name">
- <xsl:value-of select="substring-after(., ':')"/>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <xsl:if test="$nsmunge and not(@ns)">
- <xsl:choose>
- <xsl:when test="contains(@name, ':')">
- <xsl:variable name="prefix" select="substring-before(@name, ':')"/>
- <xsl:attribute name="ns">
- <xsl:value-of select="namespace::*[local-name(.) = $prefix]"/>
- </xsl:attribute>
- </xsl:when>
- <xsl:when test="self::rng:element">
- <xsl:attribute name="ns">
- <xsl:value-of select="$ns"/>
- </xsl:attribute>
- </xsl:when>
- </xsl:choose>
- </xsl:if>
- <xsl:apply-templates mode="rng.mode">
- <xsl:with-param name="first" select="$first"/>
- <xsl:with-param name="ns" select="$ns"/>
- <xsl:with-param name="nss" select="$nss"/>
- </xsl:apply-templates>
- </xsl:copy>
+ <xsl:choose>
+ <xsl:when test="$rng.strict and rng:anyName">
+ <empty/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name="nsmunge" select="self::rng:element or self::rng:attribute"/>
+ <xsl:copy>
+ <xsl:for-each select="@*">
+ <xsl:choose>
+ <xsl:when test="$nsmunge and local-name(.) = 'name' and contains(., ':')">
+ <xsl:attribute name="name">
+ <xsl:value-of select="substring-after(., ':')"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:if test="$nsmunge and not(@ns)">
+ <xsl:choose>
+ <xsl:when test="contains(@name, ':')">
+ <xsl:variable name="prefix" select="substring-before(@name, ':')"/>
+ <xsl:attribute name="ns">
+ <xsl:value-of select="namespace::*[local-name(.) = $prefix]"/>
+ </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="self::rng:element">
+ <xsl:attribute name="ns">
+ <xsl:value-of select="$ns"/>
+ </xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:if>
+ <xsl:apply-templates mode="rng.mode">
+ <xsl:with-param name="first" select="$first"/>
+ <xsl:with-param name="ns" select="$ns"/>
+ <xsl:with-param name="nss" select="$nss"/>
+ </xsl:apply-templates>
+ </xsl:copy>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template mode="rng.mode" match="rng:start">