ceki 2004/05/26 10:56:18 Modified: tests/input/xml customLevel2.xml customLevel3.xml customLogger3.xml customLogger2.xml customLevel1.xml customLogger1.xml customLevel4.xml DOMTestCase1.xml defaultInit.xml src/java/org/apache/joran Interpreter.java src/java/org/apache/log4j/joran JoranConfigurator.java Log: JoranConfigurator can also deal with existing DOCTYPE statements referring to
log4j.dtd. Thus, JoranConfigurator can really read all config files intended for DOMConfigurator (with the exception of config files with custom ErrorHanders.) Revision Changes Path 1.3 +1 -0 logging-log4j/tests/input/xml/customLevel2.xml Index: customLevel2.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/customLevel2.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- customLevel2.xml 26 May 2004 17:19:37 -0000 1.2 +++ customLevel2.xml 26 May 2004 17:56:17 -0000 1.3 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="false"> 1.3 +1 -0 logging-log4j/tests/input/xml/customLevel3.xml Index: customLevel3.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/customLevel3.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- customLevel3.xml 26 May 2004 17:19:37 -0000 1.2 +++ customLevel3.xml 26 May 2004 17:56:17 -0000 1.3 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="false"> 1.3 +1 -0 logging-log4j/tests/input/xml/customLogger3.xml Index: customLogger3.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/customLogger3.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- customLogger3.xml 26 May 2004 17:19:37 -0000 1.2 +++ customLogger3.xml 26 May 2004 17:56:17 -0000 1.3 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="true"> 1.3 +1 -1 logging-log4j/tests/input/xml/customLogger2.xml Index: customLogger2.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/customLogger2.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- customLogger2.xml 26 May 2004 17:19:37 -0000 1.2 +++ customLogger2.xml 26 May 2004 17:56:17 -0000 1.3 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> - +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="true"> 1.4 +1 -0 logging-log4j/tests/input/xml/customLevel1.xml Index: customLevel1.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/customLevel1.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- customLevel1.xml 26 May 2004 17:19:37 -0000 1.3 +++ customLevel1.xml 26 May 2004 17:56:17 -0000 1.4 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> 1.3 +1 -0 logging-log4j/tests/input/xml/customLogger1.xml Index: customLogger1.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/customLogger1.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- customLogger1.xml 26 May 2004 17:19:37 -0000 1.2 +++ customLogger1.xml 26 May 2004 17:56:17 -0000 1.3 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="false"> 1.3 +1 -0 logging-log4j/tests/input/xml/customLevel4.xml Index: customLevel4.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/customLevel4.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- customLevel4.xml 26 May 2004 17:19:37 -0000 1.2 +++ customLevel4.xml 26 May 2004 17:56:17 -0000 1.3 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration debug="true" xmlns:log4j='http://jakarta.apache.org/log4j/'> 1.3 +1 -0 logging-log4j/tests/input/xml/DOMTestCase1.xml Index: DOMTestCase1.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/DOMTestCase1.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DOMTestCase1.xml 26 May 2004 17:19:37 -0000 1.2 +++ DOMTestCase1.xml 26 May 2004 17:56:17 -0000 1.3 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <appender name="A1" class="org.apache.log4j.FileAppender"> 1.4 +1 -0 logging-log4j/tests/input/xml/defaultInit.xml Index: defaultInit.xml =================================================================== RCS file: /home/cvs/logging-log4j/tests/input/xml/defaultInit.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- defaultInit.xml 26 May 2004 17:19:37 -0000 1.3 +++ defaultInit.xml 26 May 2004 17:56:17 -0000 1.4 @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/"> 1.11 +32 -0 logging-log4j/src/java/org/apache/joran/Interpreter.java Index: Interpreter.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/joran/Interpreter.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Interpreter.java 26 May 2004 17:19:38 -0000 1.10 +++ Interpreter.java 26 May 2004 17:56:18 -0000 1.11 @@ -22,11 +22,14 @@ //mport org.apache.log4j.helpers.LogLog; import org.xml.sax.Attributes; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; +import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -72,6 +75,8 @@ Pattern pattern; Locator locator; + private EntityResolver entityResolver; + /** * The <id>actionListStack</id> contains a list of actions that are * executing for the given XML element. @@ -275,6 +280,33 @@ public void startPrefixMapping( java.lang.String prefix, java.lang.String uri) { + } + + public EntityResolver getEntityResolver() { + return entityResolver; + } + + public void setEntityResolver(EntityResolver entityResolver) { + this.entityResolver = entityResolver; + } + + + /** + * If a specific entityResolver is set for this Interpreter instance, then + * we use it to resolve entities. Otherwise, we use the default implementation + * offered by the super class. + */ + public InputSource resolveEntity(String publicId, String systemId) throws SAXException { + if(entityResolver == null) { + return super.resolveEntity(publicId, systemId); + } else { + try { + return entityResolver.resolveEntity(publicId, systemId); + } catch(IOException ioe) { + // fall back to the default implementation + return super.resolveEntity(publicId, systemId); + } + } } } 1.11 +2 -0 logging-log4j/src/java/org/apache/log4j/joran/JoranConfigurator.java Index: JoranConfigurator.java =================================================================== RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/joran/JoranConfigurator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JoranConfigurator.java 26 May 2004 17:19:38 -0000 1.10 +++ JoranConfigurator.java 26 May 2004 17:56:18 -0000 1.11 @@ -53,6 +53,7 @@ import org.apache.log4j.joran.action.SubstitutionPropertyAction; import org.apache.log4j.spi.Configurator; import org.apache.log4j.spi.LoggerRepository; +import org.apache.log4j.xml.Log4jEntityResolver; import org.xml.sax.SAXException; @@ -187,6 +188,7 @@ rs.addRule(new Pattern("*/param"), new ParamAction()); joranInterpreter = new Interpreter(rs); + joranInterpreter.setEntityResolver(new Log4jEntityResolver()); // The following line adds the capability to parse nested components joranInterpreter.addImplcitAction(new NestComponentIA()); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]