Marcus,
Try this:
schema = new InputSource("file:///F:/ZHW/test/ReqSchema.xsd");
That worked for me in a similar situation while trying to resolve the path
to my dtd location, so maybe it will work for you in this case. If not, I
defer to higher authority (ie: someone else who has a clue ;-)
Paul
> -----Original Message-----
> From: Marcus Schneller [SMTP:[EMAIL PROTECTED]
> Sent: Friday, February 15, 2002 3:32 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Still have problems validating xml file with xsd schema
>
> 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").newInstanc
> e();
> 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]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]