3 modified files
GeomConverter/src/org/lcsim/geometry/compact
diff -u -r1.39 -r1.40
--- CompactReader.java 13 Mar 2008 00:10:27 -0000 1.39
+++ CompactReader.java 13 Mar 2008 02:32:27 -0000 1.40
@@ -15,7 +15,7 @@
import org.lcsim.geometry.util.BaseIDDecoder;
import org.lcsim.material.XMLMaterialManager;
import org.lcsim.units.clhep.Constants;
-import org.lcsim.util.cache.CachingEntityResolver;
+import org.lcsim.util.xml.ClasspathEntityResolver;
import org.lcsim.util.xml.ElementFactory;
import org.lcsim.util.xml.JDOMExpressionFactory;
import org.lcsim.util.xml.ElementFactory.ElementCreationException;
@@ -28,7 +28,7 @@
* org.lcsim.geometry.GeometryReader class, which extends this.
*
* @author tonyj
- * @version $Id: CompactReader.java,v 1.39 2008/03/13 00:10:27 jeremy Exp $
+ * @version $Id: CompactReader.java,v 1.40 2008/03/13 02:32:27 jeremy Exp $
*
*/
public class CompactReader
@@ -75,9 +75,8 @@
builder.setValidation(true);
builder.setFeature("http://apache.org/xml/features/validation/schema", true);
- // Add an EntityResolver that caches to ~/.cache
- builder.setEntityResolver(new CachingEntityResolver());
- //builder.setEntityResolver(new ClasspathEntityResolver(this.getClass()));
+ // Use a classpath entity resolver to get the schemas from the jar file.
+ builder.setEntityResolver(new ClasspathEntityResolver());
doc = builder.build(in);
GeomConverter/src/org/lcsim/geometry/compact/converter/lcdd
diff -u -r1.19 -r1.20
--- Main.java 13 Mar 2008 00:10:28 -0000 1.19
+++ Main.java 13 Mar 2008 02:32:28 -0000 1.20
@@ -18,7 +18,7 @@
import org.lcsim.geometry.compact.CompactReader;
import org.lcsim.geometry.compact.Detector;
import org.lcsim.geometry.compact.converter.Converter;
-import org.lcsim.util.cache.CachingEntityResolver;
+import org.lcsim.util.xml.ClasspathEntityResolver;
import org.lcsim.util.xml.ElementFactory;
/**
@@ -63,10 +63,12 @@
stream.close();
SAXBuilder builder = new SAXBuilder();
- //builder.setEntityResolver(new ClasspathEntityResolver(this.getClass()));
- builder.setEntityResolver(new CachingEntityResolver());
+
+ builder.setEntityResolver(new ClasspathEntityResolver());
+
builder.setValidation(true);
builder.setFeature("http://apache.org/xml/features/validation/schema",true);
+
builder.build(new ByteArrayInputStream(stream.toByteArray()));
}
GeomConverter/src/org/lcsim/util/xml
diff -u -r1.3 -r1.4
--- ClasspathEntityResolver.java 13 Mar 2008 00:10:28 -0000 1.3
+++ ClasspathEntityResolver.java 13 Mar 2008 02:32:28 -0000 1.4
@@ -14,22 +14,16 @@
* Resolves URIs to class resources.
*
* For instance, the URI <code>http://www.lcsim.org/example/example.txt</code> would
- * be resolved to <code>/org/lcsim/example/example.txt</code>.
+ * be resolved to <code>org/lcsim/example/example.txt</code>.
*
* @author Jeremy McCormick
- * @version $Id: ClasspathEntityResolver.java,v 1.3 2008/03/13 00:10:28 jeremy Exp $
+ * @version $Id: ClasspathEntityResolver.java,v 1.4 2008/03/13 02:32:28 jeremy Exp $
*/
public class ClasspathEntityResolver
implements EntityResolver
-{
- Class klass;
- public ClasspathEntityResolver(Class klass)
- {
- this.klass = klass;
- }
-
+{
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
- {
+ {
URL url = new URL(systemId);
String[] hostTokens = url.getHost().split("\\.");
String org = "";
@@ -38,28 +32,15 @@
if (!hostTokens[i].equals("www"))
org += "/" + hostTokens[i];
}
-
- String fullpath = org + "/" + (new URL(systemId)).getPath();
- //InputStream in = this.getClass().getResourceAsStream(fullpath);
- InputStream in = klass.getResourceAsStream(fullpath);
-
- System.out.println("printing entity ...");
- BufferedReader xx = new BufferedReader(new InputStreamReader(in));
- String line = null;
- while ((line = xx.readLine()) != null) {
- if (line.length() > 0)
- System.out.println(line);
- }
+ org = org.substring(1);
+ String fullpath = org + (new URL(systemId)).getPath();
+
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream(fullpath);
InputSource src = new InputSource(in);
src.setSystemId(systemId);
src.setPublicId(publicId);
- System.out.println("returning InputSource ...");
- System.out.println("fullPath ..." + fullpath);
- System.out.println("systemId ... " + src.getSystemId());
- System.out.println("publicId ... " + src.getPublicId());
-
return src;
}
}
CVSspam 0.2.8