-
Notifications
You must be signed in to change notification settings - Fork 45
Fix attribute parameter #41
base: master
Are you sure you want to change the base?
Conversation
Thanks @Robbert for providing the patch and @gkholman for the bug description. @rjelliffe @tgraham-antenna Could you do the merge after review and publish an update stylesheet collection on schematron.org? We needed some time to find out what was wrong with our schematron schemas and I assume others will also invest some time. This is a quite substantial issue and because the rest of the implementation works so well you actually do not expect that this is a bug. |
@Robbert This PR seems not to fully fix the problem (or it has at least another unwanted effect). With this fix you could now use also attribute nodes as context for a rule. But when an assertion fails, the location attribute in the SVRL report has not the expected XPATH. ExampleSource File<foo>
<bar baz="hello world"/>
</foo> Schematron Schema<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<sch:pattern>
<sch:rule context="@baz">
<sch:assert test="false()">There is no attribute @baz on any element.</sch:assert>
</sch:rule>
</sch:pattern>
</sch:schema> SVRL Message <svrl:failed-assert test="false()" location="hello world">
<svrl:text>There is no attribute @baz on any element.</svrl:text>
</svrl:failed-assert>
ProblemThis following part in the schematron skeleton for saxon seems the problem. <xsl:template name="generate-default-rules">
...
<axsl:template match="*" mode="schematron-select-full-path">
<xsl:choose>
<xsl:when test=" $full-path-notation = '1' ">
<!-- Use for computers, but rather unreadable for humans -->
<axsl:apply-templates select="." mode="schematron-get-full-path"/>
</xsl:when>
...
<xsl:otherwise>
...
</xsl:otherwise>
</xsl:choose>
</axsl:template>
</xsl:template> The generated template for mode Solution?If the generated template also matches attrbiutes this seem to fix the problem <axsl:template match="@*|*" mode="schematron-select-full-path">..</axsl:template> For the example above I now get <svrl:failed-assert test="false()" location="/foo[1]/bar[1]/@baz">
<svrl:text>There is no attribute @baz on any element.</svrl:text>
</svrl:failed-assert> |
It should be noted that there is unfortunately another undesired side effect when Saxon is used: When a rule context targets e.g. the document node or an attribute node, such a node cannot have any attribute children and so Saxon will emit a warning like the following:
|
Currently the
attribute
XSLT parameter is ineffective because of the erroneousparent::node()
check. Removing the needless check should resolve issue #29, and allow attributes as rule context again.