I am not allowed to give you the full code, but I have narrowed it down to a small function which still fires the error. Try it:
FUNCTION My_FUNCTION( p NUMBER ) RETURN NUMBER IS
BEGIN
IF FALSE IS NULL
THEN
IF TRUE
THEN
SELECT XMLQuery('copy $d := $se
modify (
for $i in $d/PmtInf/DrctDbtTxInf/DrctDbtTx/MndtRltdInf/AmdmntInfDtls/OrgnlCdtrSchmeId/Id/PrvtId/Othr/SchemeNm
return rename node $i as "SchmeNm"
)
return $d' passing v AS "se" RETURNING content)
INTO v
FROM dual;
END IF;
ELSE
IF TRUE IS NOT NULL
THEN
SELECT INSERTCHILDXMLAFTER(v, '/PmtInf/PmtTpInf','SeqTp', XMLTYPE('<CtgyPurp> <Cd>' || '</Cd>
</CtgyPurp>'))
INTO v
FROM dual;
END IF;
END IF;
END My_FUNCTION;
From here on, if I change anything in the multiline strings or if I remove any of both if then else (outer) blocks, it will beautify with no error.