问题
I have the next DTD definition
<!ELEMENT testNode EMPTY>
<!ATTLIST testNode
listOfNodes IDREFS #REQUIRED
bestNode IDREF #REQUIRED
>
when I get /testNode/@listOfNodes I have to check if there are more then one ref in listOfNodes. How can I do this ?
回答1:
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"
来源:https://stackoverflow.com/questions/16980015/how-to-check-idrefs-length-in-xpath