Misztur, Chris
2014-01-11 18:13:23 UTC
Hello.
Can the below code be improved to retrieve the current effective price (4000) given the following:
for $iap in $iaps-doc/iap (: for each iaps/iap :)
return
(
let $iap-name := $iap/@name/string() (: get the iap name :)
let $effective-price :=
(for $price in $iap/price
where current-date() >= xs:date($price/@effective/string()) (: select only price nodes where @effective is <= today's date :)
order by xs:date($price/@effective/string()) descending (: order descending so the first returned price node has the most recent date :)
return $price)[1]
return element { $iap-name } { $effective-price }
)
<iaps>
<iap name="bald">
<price amount="5000" amountText="!C5000" effective="01/01/2014"/>
<price amount="4000" amountText="!C4000" effective="01/05/2014"/>
<price amount="10000" amountText="!C10000" effective="01/15/2014"/>
</iap>
</iaps>
________________________________
The contents of this message may be privileged and confidential. Therefore, if this message has been received in error, please delete it without reading it. Your receipt of this message is not intended to waive any applicable privilege. Please do not disseminate this message without the permission of the author.
Please consider the environment before printing this e-mail
Can the below code be improved to retrieve the current effective price (4000) given the following:
for $iap in $iaps-doc/iap (: for each iaps/iap :)
return
(
let $iap-name := $iap/@name/string() (: get the iap name :)
let $effective-price :=
(for $price in $iap/price
where current-date() >= xs:date($price/@effective/string()) (: select only price nodes where @effective is <= today's date :)
order by xs:date($price/@effective/string()) descending (: order descending so the first returned price node has the most recent date :)
return $price)[1]
return element { $iap-name } { $effective-price }
)
<iaps>
<iap name="bald">
<price amount="5000" amountText="!C5000" effective="01/01/2014"/>
<price amount="4000" amountText="!C4000" effective="01/05/2014"/>
<price amount="10000" amountText="!C10000" effective="01/15/2014"/>
</iap>
</iaps>
________________________________
The contents of this message may be privileged and confidential. Therefore, if this message has been received in error, please delete it without reading it. Your receipt of this message is not intended to waive any applicable privilege. Please do not disseminate this message without the permission of the author.
Please consider the environment before printing this e-mail