0

Conditionally Remove XML Element based on parameter in Java using XLST

This post demonstrates how to remove an XML element based on some parameter in Java using using XSLT.

Requirements

Stuff used.

  • Java 8 (JDK)
  • IntelliJ IDEA – optional
  • Spring Boot – optional
  • Windows 10 – optional
  • XSLT 1.0

Target XML

We want to remove COMPANY elements and transform the input message from

to

Notice COMPANY elements are now gone!

With Parameters

The codes below pass parameter to the transformer object.

XSLT File

We need to use the expression below:

Download the Codes

https://github.com/Turreta/Conditionally-Remove-XML-Element-based-on-parameter-in-Java-using-XLST

Karl San Gabriel

Karl San Gabriel

Java and Enterprise Technologies Expert