javascript – 可以在Schematron规则中使用外部脚本吗?

有没有办法在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中重用它.

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...