variables in let/@value are not replaced in abstract patterns
Variables used in <let> @value an abstract <pattern> are not replaced.
For <sch:assert>, <sch:p>, <sch:rule>, and <sch:value-of> the variables are
replaced with the values from the corresponding <param> values from the
concrete "@is-a" pattern.
However, with the <sch:let>, when using a variable as the value of the
<sch:let> in the abstract pattern (e.g. <sch:let name="test"
value="$variableToSpecifyWithParam" />) and then specify a <param> with a name
that matches the variable (i.e. <param name="variableToSpecifyWithParam"
value="true()"/>).
I found this blog entry that describes the issue and has a proposed resolution:
http://itfundamentalist.blogspot.com/2009/03/schematron-stilesheets-wont-work-wi
th.html
Original issue reported on code.google.com by madshansen3 on 25 Oct 2010 at 3:20
The attached file is a modified iso_abstract_expand.xsl that applies the
changes described in the referenced article, and appear to resolve the issue
and allow variable references in let/@value.
Original comment by madshansen3 on 27 Oct 2010 at 5:51
Attachments:
The only issue/complication I see in enabling this change is that a reference
to a <let> variable and a placeholder variable with the same name could cause
unexpected results. Especially when a let/@value in the abstract pattern is set
to the value of another let.
For instance:
<sch:let name="var1" value="false()" />
<sch:let name="var2" value="$var1"/>
<sch:assert
test="$var2"
flag="error">
<sch:value-of select="$var2"/> was assigned the value of <sch:value-of select="$var1" />
</sch:assert>
When invoked with the following parameters:
<sch:param name="var1" value="true()"/>
<sch:param name="var2" value="@test"/>
Produces:
<xsl:variable name="var1" select="false()"/>
<xsl:variable name="var2" select="true()"/>
<!--ASSERT -->
<xsl:choose>
<xsl:when test="@test"/>
<xsl:otherwise>
<svrl:failed-assert xmlns:svrl="http://purl.oclc.org/dsdl/svrl" test="@test">
<xsl:attribute name="flag">error</xsl:attribute>
<xsl:attribute name="location">
<xsl:apply-templates select="." mode="schematron-select-full-path"/>
</xsl:attribute>
<svrl:text>
<xsl:text/>
<xsl:value-of select="@test"/>
<xsl:text/> was assigned the value of <xsl:text/>
<xsl:value-of select="true()"/>
<xsl:text/>
</svrl:text>
</svrl:failed-assert>
</xsl:otherwise>
</xsl:choose>
Original comment by madshansen3 on 27 Oct 2010 at 6:02
Is there any chance to have this fixed at some point ?
About your comments some tools like <oxygen/> avoid this to happen and report
error:
"Conflict between pattern parameters and variables defined in the abstract
pattern 'codeListPattern': parameter 'vocabularyIdentifier' and variable(s):
'vocabularyIdentifier'. Please use variable names that don't start with
parameters names."
Thanks.
Original comment by [email protected] on 22 Jul 2014 at 2:53
I can see this is a bug and should be fixed. This probably comes from a confusion between xsl:variable/@select and sch:schema/@value.
The check reported for Oxygen seems to be sensible.
(Should not have been closed)
+1 on the issue. A fix to this would be nice