Question

UBlendIt strings:ReplaceVariables and escaped characters

  • 25 March 2022
  • 2 replies
  • 38 views

During deployments, we use UBlendIt’s strings:ReplaceVariables function to replace placeholders with values specified in the UDeliver registry.

If the placeholder values contains an escaped XML character (such as &):

<Data name="$[ADV.API_REF_DATA_CONTRACT_URL]" value="https://localhost:8221/reference-data/v1/customer/contract?cas-code=$[CAS_CODE]&amp;program=$[PROGRAM]&amp;validation-date=$[VALIDATION_DATE]"

strings:ReplaceVariables throws an error:

<Error>Call to strings:ReplaceVariables5(--unknown function signature--) with 5 args: Exception has been thrown by the target of an invocation.'=' is an unexpected token. The expected token is ';'. Line 7, position 152.</Error>

Anyone have any suggestions on how to work around this?

Thanks!


2 replies

Badge +1

Hi Marc,

To reproduce your issue: would you have a self-contained repro (and a USoft version/patch level)?

e.g. the following works on USoft 10 and 9.1U without that error  message.
Note that <Data name= value=/> could also be replaced by e.g. <Data name=..><value><![CDATA[..your content..]]></value></Data>

But that seems not to be needed in my example below. 

 

<?xml version="1.0" encoding="UTF-8"?>
<replacevars xmlns:pc="Processing.Command">
    
<pc:assign-string-default
    value = "lets fill in $[ADV.API_REF_DATA_CONTRACT_URL] and check the outcome"
    program = "USoft"
/>    
    
<pc:evaluate expression="strings:ReplaceVariables($value, replacements, 'name', 'value', '')">
    <replacements>
        <Data 
            name="$[ADV.API_REF_DATA_CONTRACT_URL]" 
            value="https://localhost:8221/reference-data/v1/customer/contract?cas-code=$[CAS_CODE]&amp;program=$[PROGRAM]&amp;validation-date=$[VALIDATION_DATE]"
        >
        </Data>
        <Data name="$[VALIDATION_DATE]" value="today"/>
        <Data name="$[PROGRAM]" value="{$program}"/>
        <Data name="$[CAS_CODE]" value="yeah"/>
    </replacements>
</pc:evaluate>

</replacevars>

Hi Frank, thanks for the reply.

I’m getting this error in both 9.1.1J and 10.0.1E. Some more info:

 

Exported application data in which to replace the placeholder ($diff):

<?usoft-xml version="1.0" action="multi-tables-import" use-io-formats="no" verify-original-values="no" return-corrected-records ="yes"?>
<MultiExport>
<Application_Default_Values>
<APP_DEFAULT_VALUES NAME="API_REF_DATA_CONTRACT_URL" VALUE="$[ADV.API_REF_DATA_CONTRACT_URL]" DESCRIPTION="URL of the Reference Data customer contract service" />
</Application_Default_Values>
</MultiExport>

Registry data containing the placeholder value to use ($applicationdata):

<ApplicationData>
<Data name="$[ADV.API_REF_DATA_CONTRACT_URL]" value="https://localhost:8221/reference-data/v1/customer/contract?cas-code=$[CAS_CODE]&amp;program=$[PROGRAM]&amp;validation-date=$[VALIDATION_DATE]" />
</ApplicationData>

UBlendit script snippet:

<pc:copy-of select="strings:ReplaceVariables($diff, $applicationdata, 'name', 'value', '')"/>

Result:

<InitialiseScript /><ImportAppData><CheckFileExists /><pc-assign-string replace_path="D:\Apps\usoft\APP\PCSCC\releases\7test\appdata\PCSCC.placeholders.xml" /><ReplaceData>Call to strings:ReplaceVariables5(--unknown function signature--) with 5 args: Exception has been thrown by the target of an invocation.'=' is an unexpected token. The expected token is ';'. Line 4, position 152.</ReplaceData></ImportAppData>

 

Reply