Question

There are messages:

<Employees xmlns="https://services">
    <Employee>
        <SNILS>111-111-111-1</SNILS>
        <Name>Den</Name>
        <Sex>M</Sex>
    </Employee>
</Employees>

<Employees xmlns="https://services">
    <Employee>
        <SNILS>111-111-111-2</SNILS>
        <Name>Elena</Name>
    </Employee>
</Employees>

<Employees xmlns="https://services">
    <Employee>
        <SNILS>111-111-111-3</SNILS>
        <Name>Elena</Name>
        <Sex/>
    </Employee>
</Employees>

output should be look like this:

<Employees xmlns="https://services">
    <Employee>
        <SNILS>111-111-111-1</SNILS>
        <Name>Den</Name>
        <Sex>M</Sex>
    </Employee>
</Employees>

<Employees xmlns="https://services">
    <Employee>
        <SNILS>111-111-111-2</SNILS>
        <Name>Elena</Name>
        <Sex>W</Sex>
    </Employee>
</Employees>

<Employees xmlns="https://services">
    <Employee>
        <SNILS>111-111-111-3</SNILS>
        <Name>Elena</Name>
        <Sex>W</Sex>
    </Employee>
</Employees>

we must add a new element.

  1. if it is not there
  2. if it is not empty

added a block diagram:

enter image description here

put the value I got

<enrich>
   <source xpath="get-property('VALUE')"/>
   <target xmlns:t="https://services.rosminzdrav.ru/MedStaff" action="replace" type="custom" xpath="//t:Employee/t:Sex"/>
</enrich>
  1. how to check that the element is not empty?
  2. how to add a new element?
Was it helpful?

Solution

  1. how to check that the element is not empty?

Use filter mediator and check for condition

2.how to add a new element?

You can use, payload/enrich/xslt mediators based on your requirements

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top