有没有办法在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,'01','')) = 0">versionCreated is an iso date/time (r20a4).</assert> <assert test="string-length(translate(substring(.,7,'')) = 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,'0123','')) = 0">versionCreated is an iso date/time (r20a7).</assert> <assert test="string-length(translate(substring(.,10,'')) = 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,'012','')) = 0">versionCreated is an iso date/time (r20a10).</assert> <assert test="string-length(translate(substring(.,13,'')) = 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,'012345','')) = 0">versionCreated is an iso date/time (r20a13).</assert> <assert test="string-length(translate(substring(.,16,'')) = 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,'')) = 0">versionCreated is an iso date/time (r20a16).</assert> <assert test="string-length(translate(substring(.,19,'')) = 0">versionCreated is an iso date/time (r20a17).</assert> <assert test="substring(.,20,1) = 'Z' or substring(.,1) = '+' or substring(.,1) = '-'">versionCreated is an iso date/time (r20a18).</assert> <assert test="string-length(translate(substring(.,21,'')) = 0">versionCreated is an iso date/time (r20a19).</assert> <assert test="string-length(translate(substring(.,22,'')) = 0">versionCreated is an iso date/time (r20a20).</assert> <assert test="substring(.,23,1) = ':' or substring(.,1) = ''">versionCreated is an iso date/time (r20a21).</assert> <assert test="string-length(translate(substring(.,24,'')) = 0">versionCreated is an iso date/time (r20a22).</assert> <assert test="string-length(translate(substring(.,25,'')) = 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>
谢谢你的帮助.
解决方法
我相信你正在寻找
abstract patterns.它不是脚本,但你可以重用模式.
我也发现了这个问题Formatting a Date (Sharepoint Designer)因此,您可能会尝试从sharepoint中提取架构并在schematron中重用它.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。