regex - Schematron regexp:test fails with broad expression -
i going nuts here..
the test
fails using broad match-anything regex '^.+$'
(shown in sample file) works specific '^c.+$'
i tried test="string-length(.) > 0"
, fails.
please help.
this xml file:
<article> <back><ack> <title>acknowledgements</title> <p>the authors thank <funding-source rid="sp1">cnpq</funding-source> (process numbers <award-id rid="sp1">303287/2013-6</award-id> , <award-id rid="sp1">303559/2012-8</award-id>), <funding-source rid="sp2">fapesp</funding-source> (process number <award-id rid="sp2">2012/12207-6</award-id>) , <funding-source rid="sp3">capes</funding-source> (process number <award-id rid="sp3">12357-13-8</award-id>) financial support.</p> </ack></back></article>
this schematron file fails:
<schema xmlns="http://purl.oclc.org/dsdl/schematron" querybinding="exslt" xml:lang="en"> <ns uri="http://www.w3.org/1999/xlink" prefix="xlink"/> <ns uri="http://exslt.org/regular-expressions" prefix="regexp"/> <pattern id="funding_info"> <title>make sure funding-source not happen inside p</title> <assert test="regexp:test(current(), '^.+$')"> ec-check: nao deve haver 'funding-source' nem 'award-id' dentro de 'p' </assert> </rule> </pattern> </schema>
this schematron file works:
<schema xmlns="http://purl.oclc.org/dsdl/schematron" querybinding="exslt" xml:lang="en"> <ns uri="http://www.w3.org/1999/xlink" prefix="xlink"/> <ns uri="http://exslt.org/regular-expressions" prefix="regexp"/> <pattern id="funding_info"> <title>make sure funding-source not happen inside p</title> <assert test="regexp:test(current(), '^c.+$')"> ec-check: nao deve haver 'funding-source' nem 'award-id' dentro de 'p' </assert> </rule> </pattern> </schema>
it seems backslashes in xsl can used define escape sequences. when need define regex shorthand character class, need prepend specific characters literal backslash, thus, need use double backslash:
^[\\s\\s]+$
this pattern match:
^
- start of string[\\s\\s]+
- 1 or more characters either whitespace or non-whitespace (thus, matches character)$
- end of string.
this means regex flavor not javascript, althoug this reference claims exslt uses js flavor.
Comments
Post a Comment