Xml 使用xquery拆分范围
我有一个xml,如下所示Xml 使用xquery拆分范围,xml,xquery,basex,Xml,Xquery,Basex,我有一个xml,如下所示 <content> <customer id="250"> <assert PropertyType="product" PropertyValues="0009~0013" DisplayClass="confirmed"/> <assert PropertyType="product" PropertyValues=&qu
<content>
<customer id="250">
<assert PropertyType="product" PropertyValues="0009~0013" DisplayClass="confirmed"/>
<assert PropertyType="product" PropertyValues="0001" DisplayClass="confirmed"/>
</customer>
<customer id="100">
<assert PropertyType="product" PropertyValues="0008|0010~0012" DisplayClass="confirmed"/>
</customer>
<customer id="6000">
<assert PropertyType="product" PropertyValues="0013|0036|0042|0047" DisplayClass="confirmed"/>
</customer>
</content>
我想找到assert标记中的每个PropertyValues属性,从中搜索0011值并返回一个布尔值我有不同的操作符,比如~(range)和|(separator),它们的实际意思是
PropertyValue=“0009~0013”->0009到0013-->我有序列0009 0010 0011 0013
PropertyValue=“0008 | 0010~0012”->我有0008 0010 0011 0012
PropertyValues=“0013 | 0036 | 0042 | 0047”->我有0013 0036 0042 0047 如何使用Xquery执行此操作
如有任何建议/想法,将不胜感激,谢谢 您可以使用
tokenize
功能将内容拆分,还可以使用范围运算符to
将范围语法与~
一起“翻译”为一个序列,最后您只需检查生成的序列是否包含您的值:
//@PropertyValues
!
(. || ': ' || (((tokenize(., '\|') ! (let $tokens := tokenize(., '~')!xs:integer(.) return $tokens[1] to $tokens[2])) ! format-integer(., '0001')) = '0011'))
在输出端
您可以使用
tokenize
功能将内容拆分,也可以使用范围运算符to
将范围语法与~
一起“翻译”为序列,最后只需检查生成的序列是否包含您的值:
//@PropertyValues
!
(. || ': ' || (((tokenize(., '\|') ! (let $tokens := tokenize(., '~')!xs:integer(.) return $tokens[1] to $tokens[2])) ! format-integer(., '0001')) = '0011'))
在输出端
你的问题不清楚:你想做什么?确切的预期产出是什么?你的问题不清楚:你想做什么?确切的预期产量是多少?