次の XML で、XPath 式を使用して、同じコードの地域アイテムの金額が地域アイテムの金額の 5% 以内である地域アイテム要素を選択することは可能ですか? この例では、ローカル アイテム 4 が選択されます。
<?xml version="1.0" encoding="UTF-8"?>
<Inventory>
<Local>
<Item>
<Code>1</Code>
<Amount>10000</Amount>
</Item>
<Item>
<Code>2</Code>
<Amount>20000</Amount>
</Item>
<Item>
<Code>3</Code>
<Amount>30000</Amount>
</Item>
<Item>
<Code>4</Code>
<Amount>40000</Amount>
</Item>
</Local>
<Regional>
<Item>
<Code>2</Code>
<Amount>100</Amount>
</Item>
<Item>
<Code>4</Code>
<Amount>39900</Amount>
</Item>
</Regional>
</Inventory>
これまでのところ、2 つの要素を返す以下の式で同じコードを持つローカル アイテムのみを選択できますが、「/Amount * 0.95」を追加してから、両方の要素に 0.95 を掛ける方法がわかりません。この式の最後で、最初のアイテムの金額に 0.95 を掛けた値が返されます。
/Inventory/Local/Item[Code=/Inventory/Regional/Item/Code]