maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ltheu...@apache.org
Subject svn commit: r1061702 - in /maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd: AbstractXmlValidator.java AbstractXmlValidatorTest.java
Date Fri, 21 Jan 2011 09:27:00 GMT
Author: ltheussl
Date: Fri Jan 21 09:27:00 2011
New Revision: 1061702

URL: http://svn.apache.org/viewvc?rev=1061702&view=rev
Log:
allow implementations to provide their own EntityResolver

Modified:
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java
    maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java

Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java?rev=1061702&r1=1061701&r2=1061702&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java
(original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidator.java
Fri Jan 21 09:27:00 2011
@@ -29,12 +29,12 @@ import java.util.Map;
 
 import junit.framework.AssertionFailedError;
 
-import org.apache.maven.doxia.parser.AbstractXmlParser;
 import org.apache.maven.doxia.parser.Parser;
 
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.logging.Logger;
 
+import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 import org.xml.sax.SAXNotRecognizedException;
@@ -147,6 +147,12 @@ public abstract class AbstractXmlValidat
     protected abstract Map getTestDocuments()
             throws IOException;
 
+    /**
+     * Returns the EntityResolver that is used by the XMLReader for validation.
+     *
+     * @return an EntityResolver. Not null.
+     */
+    protected abstract EntityResolver getEntityResolver();
 
     // ----------------------------------------------------------------------
     // Private methods
@@ -162,7 +168,7 @@ public abstract class AbstractXmlValidat
                 xmlReader.setFeature( "http://xml.org/sax/features/validation", true );
                 xmlReader.setFeature( "http://apache.org/xml/features/validation/schema",
true );
                 xmlReader.setErrorHandler( new MessagesErrorHandler() );
-                xmlReader.setEntityResolver( new AbstractXmlParser.CachedFileEntityResolver()
);
+                xmlReader.setEntityResolver( getEntityResolver() );
             }
             catch ( SAXNotRecognizedException e )
             {

Modified: maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java?rev=1061702&r1=1061701&r2=1061702&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/xsd/AbstractXmlValidatorTest.java
Fri Jan 21 09:27:00 2011
@@ -35,12 +35,16 @@ import java.util.Map;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
+import org.apache.maven.doxia.parser.AbstractXmlParser;
+
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.SelectorUtils;
 import org.codehaus.plexus.util.xml.XmlUtil;
 
+import org.xml.sax.EntityResolver;
+
 /**
  * Abstract class to validate XML files with DTD or XSD mainly for Doxia namespaces.
  *
@@ -102,6 +106,20 @@ public abstract class AbstractXmlValidat
     }
 
     /**
+     * Returns the EntityResolver that is used by the XMLReader for validation.
+     * By default a {@link AbstractXmlParser.CachedFileEntityResolver} is used,
+     * but implementations should override this for performance reasons.
+     *
+     * @return an EntityResolver. Not null.
+     *
+     * @since 1.1.5
+     */
+    protected EntityResolver getEntityResolver()
+    {
+        return new AbstractXmlParser.CachedFileEntityResolver();
+    }
+
+    /**
      * Find test resources in the <code>doxia-test-docs-XXX.jar</code> or in
an IDE project.
      *
      * @return a map of test resources defined as follow:



Mime
View raw message