All,
I'm using Xerces 1.4.4 here and I'm encountering some problems. I use
the external-schemaLocation property to set up schemas for those files
that need them, and that works fine.
The problem is that if you set the external-schemaLocation property and
load any file that uses a DTD, Xerces reports lots of errors, even for
valid files. In my opinion, this is a bug, since files that do not use
the right namespace should not really be affected by the external
schemas.
I attach a test program below. Run it on any file with a DTD and it will
tell you that every line is wrong.
Any ideas?
Christian
import java.util.*;
import java.io.*;
import java.net.*;
import org.w3c.dom.*;
import org.apache.xerces.parsers.*;
import org.apache.xerces.dom.*;
import org.xml.sax.*;
public class parse {
public static void main(String[] args) {
try {
String filename="catalogue.xml";
FileInputStream fi=new FileInputStream(filename);
InputSource source=new InputSource(fi);
source.setSystemId(filename);
DOMParser parser = new DOMParser();
DocErrorHandler handler=new DocErrorHandler();
parser.setErrorHandler(handler);
parser.setFeature("http://xml.org/sax/features/validation",true);
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
parser.setProperty("http://apache.org/xml/properties/schema/external-schemaLocation","foo
Schemas/DocumentSet.xsd");
parser.parse(source);
if (handler.getErrorCount()>0)
System.out.println(handler.getMessage());
}
catch (Exception e) {
System.err.println(e);
}
}
}
class DocErrorHandler implements ErrorHandler {
int count=0;
String msg="";
public int getErrorCount() {
return count;
}
public String getMessage() {
return msg;
}
public void error(SAXParseException e) {
msg=msg+"[Error on line "+e.getLineNumber()+"]\n";
msg=msg+e.toString()+"\n\n";
count++;
}
public void fatalError(SAXParseException e) {
msg=msg+"[Error on line "+e.getLineNumber()+"]\n";
msg=msg+e.toString()+"\n\n";
count++;
}
public void warning(SAXParseException e) {
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]