如何在 xPath 中检查 IDREFS 长度 [英] How to check IDREFS length in xPath

查看:16
本文介绍了如何在 xPath 中检查 IDREFS 长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下一个DTD定义

    <!ELEMENT testNode EMPTY>
    <!ATTLIST testNode
          listOfNodes IDREFS #REQUIRED
          bestNode IDREF #REQUIRED
    >

当我得到 /testNode/@listOfNodes 时,我必须检查 listOfNodes 中是否有多个引用.我怎样才能做到这一点 ?

when I get /testNode/@listOfNodes I have to check if there are more then one ref in listOfNodes. How can I do this ?

推荐答案

如果属性 listOfNodes 中有多个 IDREF vlues,则必须按照 DTD 规则用空格分隔.因此,您可以按照此示例检查多个值:

If you have multiple IDREF vlues in attribute listOfNodes, it must be separated by space as per DTD rules. So, you may follow this example to check multiple values:

let $x := <testNode listOfNodes="d1 d2"/>
return
  if(contains($x/@listOfNodes, ' '))
  then "Yes"
  else "No"

对于多个值,它将返回是",否则返回否"

For multiple value it will return "Yes" otherwise "No"

这篇关于如何在 xPath 中检查 IDREFS 长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆