Spring XML Marshalling with XOM


Keywords
java, spring, spring-boot, xml, xom, xpath
License
MIT

Documentation

spring-xom-marshaller

Maven Central Build Nightly build

Spring XML Marshalling with XOM

Maven

<dependency>
  <groupId>com.itelg.spring</groupId>
  <artifactId>spring-xom-marshaller</artifactId>
  <version>1.3.0</version>
</dependency>

Examples

Enable auto-configuration via annotation

@Autowire XomMarshaller for further use in MarshallingHttpMessageConverter or MarshallingMessageConverter.

@SpringBootApplication
@EnableXomMarshaller
public class Application
{
    @Autowired
    private XomMarshaller xomMarshaller;
    
    public static void main(String[] args) throws Exception
    {
        SpringApplication.run(Application.class, args);
    }
}
Example-Writer
@Component
public class IntegerWriter extends AbstractWriter<Integer>
{
    @Override
    protected Element doWrite(Integer integer)
    {
        Element rootElement = new Element("integer");
        Element valueElement = new Element("value");
        valueElement.appendChild(integer.toString());
        rootElement.appendChild(valueElement);

        return rootElement;
    }
}

Build & Release

Build

mvn clean package

Release

mvn clean deploy