Skip to Content

Java Mapping remove xsi:nil='true' from payload

Hello all,

I am a new in PI, there need to remove character xsi:nil='true'.

I tried to use Graphic mapping and XSLT mapping for this. However, these two methods need to verify the validity of the XML file first.

Below are xml structure, could someone help this?

Many thanks in advance,





ID ZZJ12FJ81 is not authorised for policy 31444</ns3:errorDescription>

xmlns:ns4='' xsi:nil='true'/>






Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 15 at 03:23 PM

    Hi Nero!

    Read input payload as text with java mapping and replace "xsi:nil" with empty string.

    Regards, Evgeniy.

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 16 at 12:30 AM

    Hi Nero,

    Why do you want to remove that? you can request the source system owner to provide the XSD and handle the xsi:nil .

    If you want to remove xsi:nil from the element, you can use boolean function "isNil" and an "if" statement to pass an empty constant-



    captures.png (57.6 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
               try {
                   InputStream inputstream = transformationInput.getInputPayload().getInputStream();
                   OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
                   // a) Copy Input content to String
                   byte[] b = new byte[inputstream.available()];
                   String inputContent = new String(b);
                   inputContent = inputContent.replaceAll("<?xml version= \"1.0\" encoding= \"UTF-8\" ?>", "");
               } catch (Exception exception) {
                   throw new StreamTransformationException(exception.toString());