001package org.kuali.common.util.xml.spring; 002 003import org.kuali.common.util.xml.jaxb.JAXBXmlService; 004import org.kuali.common.util.xml.service.XmlService; 005import org.springframework.context.annotation.Bean; 006import org.springframework.context.annotation.Configuration; 007 008/** 009 * <p> 010 * The XML log4j knows how to parse, contains both an element and an attribute that have the colon character in their name. A colon is almost universally used to represent a 011 * namespace prefix, but in the XML for log4j, the colon is part of the node name. This config class returns an XML service capable of correctly parsing XML that uses the colon 012 * character in attribute and element names. 013 * 014 * <pre> 015 * <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> 016 * </log4j:configuration> 017 * </pre> 018 * 019 * </p> 020 * 021 * <p> 022 * The technique being used to handle log4j.xml parsing is to leverage a SAX parser that is not namespace aware (and thus treats the colon character just like any other character). 023 * This is described in more detail on Blaise Doughan's blog - http://blog.bdoughan.com/2011/05/jaxb-and-dtd.html 024 * </p> 025 */ 026@Configuration 027public class Log4JXmlServiceConfig { 028 029 @Bean 030 public XmlService xmlService() { 031 // Not using MOXy with log4j because it gets confused by the attributes with colon's in the name whereas the 032 // reference implementation that ships with the JDK has no issues as long as you also use a non-namespace aware 033 // parser. 034 return new JAXBXmlService.Builder().useNamespaceAwareParser(false).useEclipseLinkMoxyProvider(false).build(); 035 } 036}