SpringBoot/Jackson 2.13.x - outputting standalone="yes" in XML Header

498 views Asked by At

I'm configuring my ObjectMapper/XmlMessageConverter in Spring Boot with the following Beans:

    @Bean
    public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder()
    {
        final AnnotationIntrospector introspector = new JaxbAnnotationIntrospector(TypeFactory.defaultInstance());
        return new Jackson2ObjectMapperBuilder().serializationInclusion(JsonInclude.Include.NON_NULL).defaultUseWrapper(false)
                                                .annotationIntrospector(introspector);
    }
    
    @Bean
    @Autowired
    public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter(Jackson2ObjectMapperBuilder builder)
    {
        final XmlMapper xmlMapper = builder.createXmlMapper(true).build();
        xmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
        xmlMapper.getFactory().getXMLOutputFactory().setProperty(WstxOutputProperties.P_USE_DOUBLE_QUOTES_IN_XML_DECL, true);
        return new MappingJackson2XmlHttpMessageConverter(xmlMapper);
    }

But I can't seem to find a way for force the output of standalone="yes" into the xml header.

Does anyone know how I can do this?

1

There are 1 answers