有没有办法在Schematron规则文件中调用Javascript函数?
我很确定引擎接受规则文件并从中生成XSLT,但是想知道我是否能以某种方式在该规则文件中包含最终将在XSLT中出现的脚本?
除此之外,对于涉及大量字符串解析的验证规则也很有用,例如:
<rule context="nar:versionCreated">
<assert test="string-length(translate(substring(.,1, 1), '12','')) = 0">versionCreated is an iso date/time (r20a1).</assert>
<assert test="string-length(translate(substring(.,2, 3), '0123456789','')) = 0">versionCreated is an iso date/time (r20a2).</assert>
<assert test="substring(.,5, 1) = '-'">versionCreated is an iso date/time (r20a3).</assert>
<assert test="string-length(translate(substring(.,6, 1), '01','')) = 0">versionCreated is an iso date/time (r20a4).</assert>
<assert test="string-length(translate(substring(.,7, 1), '0123456789','')) = 0">versionCreated is an iso date/time (r20a5).</assert>
<assert test="substring(.,8, 1) = '-'">versionCreated is an iso date/time (r20a6).</assert>
<assert test="string-length(translate(substring(.,9, 1), '0123','')) = 0">versionCreated is an iso date/time (r20a7).</assert>
<assert test="string-length(translate(substring(.,10, 1), '0123456789','')) = 0">versionCreated is an iso date/time (r20a8).</assert>
<assert test="substring(.,11, 1) = 'T'">versionCreated is an iso date/time (r20a9).</assert>
<assert test="string-length(translate(substring(.,12, 1), '012','')) = 0">versionCreated is an iso date/time (r20a10).</assert>
<assert test="string-length(translate(substring(.,13, 1), '0123456789','')) = 0">versionCreated is an iso date/time (r20a11).</assert>
<assert test="substring(.,14, 1) = ':'">versionCreated is an iso date/time (r20a12).</assert>
<assert test="string-length(translate(substring(.,15, 1), '012345','')) = 0">versionCreated is an iso date/time (r20a13).</assert>
<assert test="string-length(translate(substring(.,16, 1), '0123456789','')) = 0">versionCreated is an iso date/time (r20a14).</assert>
<assert test="substring(.,17, 1) = ':'">versionCreated is an iso date/time (r20a15).</assert>
<assert test="string-length(translate(substring(.,18, 1), '012345','')) = 0">versionCreated is an iso date/time (r20a16).</assert>
<assert test="string-length(translate(substring(.,19, 1), '0123456789','')) = 0">versionCreated is an iso date/time (r20a17).</assert>
<assert test="substring(.,20, 1) = 'Z' or substring(.,20, 1) = '+' or substring(.,20, 1) = '-'">versionCreated is an iso date/time (r20a18).</assert>
<assert test="string-length(translate(substring(.,21, 1), '012345','')) = 0">versionCreated is an iso date/time (r20a19).</assert>
<assert test="string-length(translate(substring(.,22, 1), '0123456789','')) = 0">versionCreated is an iso date/time (r20a20).</assert>
<assert test="substring(.,23, 1) = ':' or substring(.,23, 1) = ''">versionCreated is an iso date/time (r20a21).</assert>
<assert test="string-length(translate(substring(.,24, 1), '012345','')) = 0">versionCreated is an iso date/time (r20a22).</assert>
<assert test="string-length(translate(substring(.,25, 1), '0123456789','')) = 0">versionCreated is an iso date/time (r20a23).</assert>
</rule>
把它变成类似的东西:
<rule context="nar:versionCreated">
<assert test="jscript:IsISOFormattedDateTime(.)">versionCreated is not a properly formatted date/time.</assert>
</rule>
感谢您的帮助。
答案 0 :(得分:1)
我相信你正在寻找abstract patterns。它不是脚本,但您可以重用模式。
我也发现了这个问题Formatting a Date (Sharepoint Designer) 因此,您可能会尝试从sharepoint中提取架构并在schematron中重用它。