Closed floyd8787 closed 1 year ago
I tested it with the latest Saxon HE version 11.4 and it works without a problem. The above test outputs:
<?xml version="1.0" encoding="UTF-8"?>
<svrl:schematron-output xmlns:svrl="http://purl.oclc.org/dsdl/svrl" title="" schemaVersion="">
<svrl:ns-prefix-in-attribute-values prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
<svrl:active-pattern document="[edited]\ph-schematron\ph-schematron-xslt\src\test\resources\issues\github137\test.xml" />
<svrl:fired-rule context="tag1" />
<svrl:failed-assert location="/tag1[1]" test="matches(tag2,'^[0-9]4$')">
<svrl:text>Invalid value</svrl:text>
</svrl:failed-assert>
</svrl:schematron-output>
My assumption is that you are running an old Saxon version of Xalan or some other non-compliant XSLT solution.... Please check your Maven dependencies
I tested it with the latest Saxon HE version 11.4 and it works without a problem. The above test outputs:
<?xml version="1.0" encoding="UTF-8"?> <svrl:schematron-output xmlns:svrl="http://purl.oclc.org/dsdl/svrl" title="" schemaVersion=""> <svrl:ns-prefix-in-attribute-values prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" /> <svrl:active-pattern document="[edited]\ph-schematron\ph-schematron-xslt\src\test\resources\issues\github137\test.xml" /> <svrl:fired-rule context="tag1" /> <svrl:failed-assert location="/tag1[1]" test="matches(tag2,'^[0-9]4$')"> <svrl:text>Invalid value</svrl:text> </svrl:failed-assert> </svrl:schematron-output>
My assumption is that you are running an old Saxon version of Xalan or some other non-compliant XSLT solution.... Please check your Maven dependencies
<svrl:failed-assert location="/tag1[1]" test="matches(tag2,'^[0-9]4$')">
see test
attribute value, regex lose curly brackets
Ah, you mean a missing curly brace :)
But this regular expression is also good: '^[0-9]4$
It matches the following values: 04
, 14
, 24
, ... 94
Yes curly braces :)
I expect value that matches ^[0-9]{4}$
. For example: 2222
, 4509
. I.e curly braces are reqiured. I use curly braces in mysch.sch, but svrlResourceError.getTest()
return without braces
Ahhhhhhh........ Looking at it
With the pure version the result is correctly - so somewhere in the transformation XSLT
With SchXslt it also works without an issue
Yes, validation works without an issue. I speak about method SVRLResourceError#getTest(). Result of this method not equals original expression
This is some XSLT magic I don't understand.
It seems like we're talking about "value templates" here, according to https://www.w3.org/TR/xslt-30/#value-templates and there it is forbidden to use single curly braces. I would need some intel from an XSLT expert here.
Anyway, by using the "SchXslt" version, you should be getting the correct result, because SchXslt is not using XSLT to provide the value but passes the value natively in the XSLT.
ISO Schematron stub created XSLT:
<xsl:template name="process-assert">
<xsl:param name="test"/>
...
<svrl:failed-assert test="{$test}" >
...
</xsl:template>
SchXslt created XSLT:
<template match="tag1" mode="w13aab3" priority="0">
...
<if test="not(matches(tag2,'^[0-9]{4}$'))">
<ns1:failed-assert xmlns:ns1="http://purl.oclc.org/dsdl/svrl" location="{schxslt:location(.)}">
<attribute name="test">matches(tag2,'^[0-9]{4}$')</attribute>
<ns1:text>Invalid value</ns1:text>
</ns1:failed-assert>
</if>
...
</template>
Sorry :(
If anyone has a smart proposal on how to resolve this, I'd be happy, I am out of ideas. Closing this for now.
I use the
match
function in mymysch.sch
fileAnd I have
test.xml
fileI wrote a test
But it's failed, because
svrlResourceError.getTest()
returnmatches(tag2,'^[0-9]4$')
, lose curly brackets. Why? How to fix it ? My version ph-schematron is 5.2.0 Thx,