xsd:assert(复杂的字符验证)

xsd:assert (complicated character verification)

有没有办法验证模板是否只包含那些传递给@param 的字符?

我考虑过使用 xpath 函数 (fn:) 的选项,但没有找到合适的选项。

这是 2 个有效 xml 例如:

<rule type="myRule" template="A-B-CB">
  <attribute param="B"/>
  <attribute param="A"/>
  <attribute param="C"/>
</rule> 


<rule type="myRule" template="A(C)-B">
  <attribute param="C"/>
  <attribute param="A"/>
  <attribute param="B"/>
</rule> 

和 2 无效 xml:

<rule type="myRule" template="AB-CD">
  <attribute param="A"/>
  <attribute param="B"/>
  <attribute param="C"/>
</rule> 


<rule type="myRule" template="AC">
  <attribute param="A"/>
  <attribute param="B"/>
  <attribute param="C"/>
</rule>

也许有关于如何使用 schematrone 或其他方式实现它的想法?

所以@template中的字母组必须与./attribute/@param中的字母组完全相同?

也就是说distinct-values(string-to-codepoints(replace(@template, '\P{L}', '')))必须和distinct-values(attribute/@param/string-to-codepoints())是同一个集合。

那么如何断言两个序列在​​排列下包含相同的值?

在 XPath 3.1 中,deep-equal(sort($X), sort($Y))

在 XPath 2.0 中,我想不出比

更好的东西了
empty($X[not(.=$Y)]) and empty($Y[not(.=$X)])

我会让你把这些放在一起。