001/**
002 * Copyright 2010-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.common.util.xml.spring;
017
018import org.kuali.common.util.xml.jaxb.JAXBXmlService;
019import org.kuali.common.util.xml.service.XmlService;
020import org.springframework.context.annotation.Bean;
021import org.springframework.context.annotation.Configuration;
022
023/**
024 * <p>
025 * 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
026 * 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
027 * character in attribute and element names.
028 * 
029 * <pre>
030 * &lt;log4j:configuration  xmlns:log4j="http://jakarta.apache.org/log4j/">
031 * &lt;/log4j:configuration>
032 * </pre>
033 * 
034 * </p>
035 * 
036 * <p>
037 * 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).
038 * This is described in more detail on Blaise Doughan's blog - http://blog.bdoughan.com/2011/05/jaxb-and-dtd.html
039 * </p>
040 */
041@Configuration
042public class Log4JXmlServiceConfig {
043
044        @Bean
045        public XmlService xmlService() {
046                // Not using MOXy with log4j because it gets confused by the attributes with colon's in the name whereas the
047                // reference implementation that ships with the JDK has no issues as long as you also use a non-namespace aware
048                // parser.
049                return new JAXBXmlService.Builder().useNamespaceAwareParser(false).useEclipseLinkMoxyProvider(false).build();
050        }
051}