XQuery - update

Help me, Please!!
Reading works
Query:
declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
for $a in input()/letter/status/user
where tf:getInoId($a)= 5 and $a = ‘BE6C30E174350000’
return $a
Return:
<xq:result …>
BE6C30E174350000
</xq:result>

And when I try to update
Query:
declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
update for $a in input()/letter/status/user
where $a = ‘BE6C30E174350000’ and tf:getInoId($a)= 5
do(
replace $a with attribute flag1 {55555555555}
)
Return:
<ino:message ino:returnvalue=“6450”>
<ino:messagetext ino:code=“INOXQE6450”>Update results in non-well-formed document</ino:messagetext>
</ino:message>
Note:
flag1 - have type “xs:long”

Approximate XML:

... BE6C30E174350001 BE6C30E174350002 BE6C30E174350003 BE6C30E174350004

That it is necessary to make that worked??

Thanks in advance for any help.

you try to replace an element by an attribute.

declare namespace tf=“http://namespaces.softwareag.com/tamino/TaminoFunction
update for $a in input()/letter/status/user
where $a = ‘BE6C30E174350000’ and tf:getInoId($a)= 5
do(
replace $a/@flag1 with attribute flag1 {55555555555}
)