[Schematron] Two significant problems with iso_schematron_skeleton_for_saxon.xsl
G. Ken Holman
gkholman at CraneSoftwrights.com
Tue Dec 6 17:30:36 EST 2011
I've just unfortunately spent an inordinate amount of time I don't
have helping a Schematron user work with UBL documents in an XSLT 2
environment, discovering two significant problems in the
iso_schematron_skeleton_for_saxon.xsl file that have been the roots
of his problem.
These problems do not exist in the XSLT 1 environment and have been
introduced in the XSLT 2 environment for Schematron (at least for the
Users of UBL who use Crane's "Context/Value Association to
Schematron" conversion environment have no problems using XSLT 1:
This particular user adapted my code in his environment for XSLT 2
and the following skeleton problems have come to light:
(1) The auto-detect of the use of attributes in context expressions
does not accommodate rules that are incorporated in the schema using
the <sch:include> directive ... it appears to only look at the rules
found in the base schema:
<xsl:when test="//iso:rule[contains(@context,'@') or
The away around the above is to assemble all of the fragments into a
single Schematron schema, and then the "//iso:rule" will visit all of
the rules in the full schema. But the above will not work if the
schema stays in fragments.
(2) Even passing an arbitrary value of "true" for $attributes at
invocation still does not add the attribute pattern to the context
XPath because of the following top-level variable:
<xsl:if test="$attributes='true' and parent::node() ">@*|</xsl:if>
My understanding is that in XSLT top-level variables are evaluated
assuming the context of the document node of the input
document. This document node has no parent. The "and
parent::node()" expression above will *always* evaluate to false,
thus never adding "@*|" to the XPath expression. My read of the
above is that in this stylesheet it is impossible to trigger the
inclusion of attributes in the search contexts of the stylesheet
created by Schematron. Why would it have been included and how was it tested?
I have suggested the user hack the above to be:
... and to use "attributes=true" on the command line when invoking
the stylesheet with a fragmented Schematron schema in order to avoid
the auto-detect bug of not looking for attributes in rules of
included Schematron fragments.
The user is now successfully detecting attributes in his input
data. No changes were needed for Crane's environment ... the problem
was entirely in the skeleton.
Please advise if I have misunderstood the situation.
I hope this helps in the maintenance of the skeleton. Certainly
users of the OASIS code list environment for documents with
attributes (as in UBL) will appreciate the skeleton being fixed.
. . . . . . . . . Ken
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman at CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
More information about the Schematron