【发布时间】:2014-06-30 14:29:30
【问题描述】:
我有一个要求,我必须根据 constant.xml 中存在的数据验证传入数据。
下面说的是我的常量文件:
<Constant>
<data>
<Nation>India</Nation>
<EndPointURL>customers/{$custID}/Resource</EndPointURL>
</data>
<data>
<Nation>China</Nation>
<EndPointURL>customers/{$custID}/Resource</EndPointURL>
</data>
<data>
<Nation>Russia</Nation>
<EndPointURL>customers/Resource</EndPointURL>
</data>
</Constant>
和$body如下:
<body>
<custID>1234</custID>
<Country>India</Country>
<ServiceURL>customers/1234/Resource</ServiceURL>
</body>
这里我必须检查一下,如果 $body/ServiceURL = $Constant/data/EndPointURL。
数据的基数是(1...无穷大)。
他们是我可以更改通过原始 CustID fr4om 输入并与客户/{$custID}/Resource 进行验证检查的一种方式。
目前,我正在使用以下代码进行检查。
let $ServiceURL :=$body/ServiceURL/text()
let $country :=$body/Country/text()
for $service in ($Constant/data) where
($service/Nation/text() = $Country)
and ($service/EndPointURL/text() = $ServiceURL)
return
<ServiceURL>{fn:concat('/REALTime/',$service/EndPointURL/text())}</ServiceURL>
};
请告诉我,如何在 xquery 中更改 constant.xml 的数据
【问题讨论】: