【问题标题】:cts search to test if the element is not availablects 搜索以测试元素是否不可用
【发布时间】:2017-04-06 11:39:38
【问题描述】:

下面是我想要获取元素 co:isbn 不可用的条目的 XML 结构:-

<tr:trackingRecord xmlns:tr="https://www.mla.org/Schema/Tracking/tr"
    xmlns:co="https://www.mla.org/Schema/commonModule/co"
    xmlns:r="http://www.rsuitecms.com/rsuite/ns/metadata">
    <tr:journal>
        <tr:trackingDetails>
            <tr:entry>
                <co:trackingEntryID>2015323313</co:trackingEntryID>
                <co:publicationDate>2015</co:publicationDate>
                <co:volume>21</co:volume>
            </tr:entry>
            <tr:entry>
                <co:trackingEntryID>2015323314</co:trackingEntryID>
                <co:publicationDate>2015</co:publicationDate>
                <co:isbn>
                    <co:entry>NA</co:entry>
                    <co:value>1234567890128</co:value>
                </co:isbn>
            </tr:entry>
            <tr:entry>
                <co:trackingEntryID>2015323315</co:trackingEntryID>
                <co:publicationDate>2015</co:publicationDate>
                <co:volume>21</co:volume>
                <co:isbn></co:isbn>
            </tr:entry>
            <tr:entry>
                <co:trackingEntryID>2015323316</co:trackingEntryID>
                <co:publicationDate>2015</co:publicationDate>
                <co:volume>21</co:volume>
            </tr:entry>
        </tr:trackingDetails>
    </tr:journal>
</tr:trackingRecord>

请建议相同的 cts:query。

【问题讨论】:

标签: xquery marklogic cts


【解决方案1】:

如果可以编辑xml结构,在entry元素中添加一个属性,比如

<tr:entry isbnPresent="yes"> for isbn present,
<tr:entry isbnPresent="no"> for isbn absent

并基于这些现场火搜索,

cts:element-attribute-value

就可以了。

不编辑架构,试试,,,

for $i in cts:search(//tr:entry,"2015")
return if(fn:exists($i//co:isbn)) then () else $i

【讨论】:

  • 添加属性也需要架构更改。我们不想做的。在不改变 XML 结构的情况下,我们可以做些什么吗?
  • 检查 fn:exists 与上面给出的迭代器,因为它可能会减慢大文件的操作
猜你喜欢
  • 2013-11-16
  • 2015-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-15
  • 2016-01-19
  • 1970-01-01
相关资源
最近更新 更多