Schematron & XPath 2.0 string/numeric comparisons
Posted: Tue Mar 22, 2011 7:59 pm
I recently added queryBinding="xslt2" to my Schematron so I could use XPath 2.0. After doing so, it seems all of my assertion tests containing comparisons of > or < are having issues (reporting incorrectly.) It seems inequality tests are not working out.
e.g.
schema:
samples:
fails
passes
passes
Specifying the attributes as numbers seems to resolve the issue:
All previous examples pass.
I understand the notion of string vs. numeric comparison, but I thought this was taken care of for you since it worked before adding xslt2 to the schema. Is this a bug, am I missing something, or must I add number() all over my schema?
cheers,
-X
e.g.
schema:
Code: Select all
<pattern id="limit_order">
<rule context="foo" role="error">
<assert test="not(@l_lim > @h_lim)">
Limits must be in high/low order.</assert>
</rule>
</pattern>
Code: Select all
<foo l_lim="50" h_lim="255" />
Code: Select all
<foo l_lim="200" h_lim="255" />
Code: Select all
<foo l_lim="050" h_lim="255" />
Specifying the attributes as numbers seems to resolve the issue:
Code: Select all
<pattern id="limit_order">
<rule context="foo" role="error">
<assert test="not(number(@l_lim) > number(@h_lim))">
Limits must be in high/low order.</assert>
</rule>
</pattern>
I understand the notion of string vs. numeric comparison, but I thought this was taken care of for you since it worked before adding xslt2 to the schema. Is this a bug, am I missing something, or must I add number() all over my schema?
cheers,
-X