Hi Paul,
your ansewer came very fast. Thank you!
Actually I tried that with the MyResolver class: here is the code:
import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; import java.io.FileReader; import java.io.FileNotFoundException;
public class MyResolver implements EntityResolver{
private FileReader schema;
public InputSource resolveEntity (String publicId, String systemId)
{
System.out.println("Hello");
if (publicId.equals("http://www.zhwin.ch/schnemac/Req") || systemId.equals("ReqSchema.xsd")) { try{
schema = new FileReader("F:/ZHW/test/ReqSchema.xsd");
}
catch(FileNotFoundException f){
System.out.println(f.getMessage());
}
}
return new InputSource(schema);
}
}
In the class were the parser is, I created a new objekt of the MyResolver:
private DocProcessor processor;
private SAXParser parser;
private MyResolver resolver;
public InputDocumentHandler() {
try{
processor = new DocProcessor();
resolver = new MyResolver();
}
catch(IOException i){
System.out.println( i.getMessage());
}
try {
parser = (SAXParser)Class.forName("org.apache.xerces.parsers.SAXParser").newInstance();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setContentHandler(processor);
parser.setErrorHandler(processor);
parser.setEntityResolver(resolver);
parser.setReaderFactory(new StreamingCharFactory());
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
Well, still the same General Schema Error........
My first guess was, that I may have to set a new feature, but I couldn't find an appropriate feature.
I may add here, that first I wroked with JDOM, but that didn't work because the parser is reading from a BufferedReader wich comes from a Socket. Ant there is the problem with the End of File and the close the BufferedReader thing.
Well, I'm pretty at a loss now......
Any idea what the problem could be?
Marcus
Cooper, Paul A wrote:
Marcus....
Rather than adding the resolveEntity method to your processor, you need to create a new MyEntityResolver class that implements the EntityResolver interface, and override the single resolveEntity method. Then pass a new instance of this class to the parser.setEntityResolver() method. Examine Laura's code a little more closely, and you'll notice that is what she did.
I had the exact same problem about 3 months ago, and implementing the entityResolver solved the problem.
Paul Cooper GlaxoSmithKline Bioinformatics
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
