Keyword replacement within xpath expression


(Lisa) #1

Hi,

I have a basic XML file I’m wanting to use as a name/ID lookup within an asset listing for a data record.

The problem I’m having is that I can’t get keyword replacements to work in the xpath expression.

e.g. using a hard coded name it works and returns the ID:
%globals_asset_contents_raw:12345^xpath:://lookup/name[.="Brisbane City"]/@id%

But trying to use the data source value as a keyword replacement I get no joy:
%globals_asset_contents_raw:12345^xpath:://lookup/name[.="{ds__region}"]/@id%

Assuming 12345 is the XML file asset, and %ds__region% is the data source value I want to look up in the xpath expression.
Sample XML:

<lookup>
    <name id="brisbane-city">Brisbane City</name>
    <name id="cairns">Cairns</name>
</lookup>

Am I just missing something basic (please let that be the case) or is it not possible?

Cheers,
Lisa


(Tarman) #2

@LisaB I do not think that is possible because globals gets replaced in the global context, which doesn’t have the concept of knowing what ds__name is for.


(Lisa) #3

Sorry for the slow reply (I was away) but thanks for your help.
I’ve ended up using Server Side JS that creates arrays of the region names and IDs and looks it up that way.