View Javadoc

1   package org.kuali.common.util.xml.spring;
2   
3   import org.kuali.common.util.xml.jaxb.JAXBXmlService;
4   import org.kuali.common.util.xml.service.XmlService;
5   import org.springframework.context.annotation.Bean;
6   import org.springframework.context.annotation.Configuration;
7   
8   /**
9    * <p>
10   * 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
11   * 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
12   * character in attribute and element names.
13   * 
14   * <pre>
15   * &lt;log4j:configuration  xmlns:log4j="http://jakarta.apache.org/log4j/">
16   * &lt;/log4j:configuration>
17   * </pre>
18   * 
19   * </p>
20   * 
21   * <p>
22   * 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).
23   * This is described in more detail on Blaise Doughan's blog - http://blog.bdoughan.com/2011/05/jaxb-and-dtd.html
24   * </p>
25   */
26  @Configuration
27  public class Log4JXmlServiceConfig {
28  
29  	@Bean
30  	public XmlService xmlService() {
31  		// Not using MOXy with log4j because it gets confused by the attributes with colon's in the name whereas the
32  		// reference implementation that ships with the JDK has no issues as long as you also use a non-namespace aware
33  		// parser.
34  		return new JAXBXmlService.Builder().useNamespaceAwareParser(false).useEclipseLinkMoxyProvider(false).build();
35  	}
36  }