Add attribute to existing document element

Hi all.

I am modifying an existing cSO implementation. As part of that modification, I need to add an attribute to an element of a document that already exists in my Tamino database. I’ll need to determine if the element has been placed previously and if so, update the value. I’m not having much luck.

My methodology is to create a Tamino connection in cSO, run the update query and disconnect but it is not working. The original version of the code does not have logic to test if the element exists, but fails with what appears to be a pretty basic error that I have not been able to figure out. The simple code and error message are below. I borrowed the code from another section of the existing sequences and switched the property names and attribute reference. 1 difference in the 2 scenarios is that although both hit the same Tamino document, the original is updating an attribute that already exists.

Does anybody have a suggestion how to revise the code so it works from the cSO Tamino call rather than using an API call?

$OrderNumber and $tripNumber are cSO properties.

update for $a in input()/Order  where $a/@orderNumber="{"$OrderNumber"}" do replace $a/@tripNumber with attribute tripNumber  {{"{"$tripNumber"}"}' 

xbd.error.text = Exception: “javax.xml.transform.TransformerException: A node test that matches either NCName:* or QName was expected.” in sequence “http://localhost:8080/mimsDevelopmentGateway/RequestTripOrders-seq.xml” at line 145.