Closed FlorianTim closed 8 months ago
I guess this is the same as #88 and #91 ...???
Ok, the issue seems to have the same cause as #88 and #91.
Unfortunately, we are legally bound to the use of the Schematron files.
Is it likely that the bug will be fixed in the near future? Or is there a viable workaround?
Are there any ways to assist in correcting the bug? Maybe there is a unit test or module we can look at.
Thank you very much for your support. :)
Well, I would suggest you move from pure to the xslt based version - that one handles the dynamic let
parts more correct - of course at the expense of runtime ;-) hth
See https://github.com/qligier/Schematronix as a possible way on how to inject variables differently
As a follow-up to my recent comment, let's consider the following XML example.
<xml>
<owner id="o1">
<car id="c1" owner="o1">
<owner id="o2">
<car id="c2" owner="o2">
<car id="c3" owner="o2">
</xml>
Assuming the usage of the Pure Schematron implementation, I'm wondering how one would write a validation schema that verifies that an owner does not have multiple cars?
The context of the rule could be either /xml/owner
or /xml/car
and we would have to store the id of the owner in a variable and use its evaluated value in a XPath filter predicate to count the <car>
occurences.
With my current understanding, the Schematron schema would look like
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xpath2">
<pattern>
<rule context="/xml/owner">
<let name="id" value="@id"/>
<report test="count(/xml/car[@owner eq $id]) gt 1">Owner <value-of select="$id"/> has more than 1 car</report>
</rule>
</pattern>
</schema>
or
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xpath2">
<pattern>
<rule context="/xml/car">
<let name="owner" value="@owner"/>
<report test="count(/xml/car[@owner eq $owner]) gt 1">Owner <value-of select="$owner"/> has more than 1 car</report>
</rule>
</pattern>
</schema>
With this issue, is that kind of validation even possible? Is there a technique or trick that I don't know about? Regards
You are right. I will see, that I get it implemented accordingly....
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Part of the 8.0.0 release - finally :)
Schematron implementation: Pure Module: ph-schematron-pure Versions: 7.1.0, 7.0.1, 7.0.0, 6.3.4, ...
Description: As soon as we compare an attribute with a variable in an expression, the expression evaluates to false although both contain the same value. However, if we compare the variable or value individually with the literal, the expression evaluates correctly to true.
Example: @listName = $list-name // evaluates to false but @listName = 'cpv' // evaluates to true 'cpv'= @listName // evaluates to true
Full Example: