I have the same problem. I don't change the file, but I do put in a DTD:
private void parseFile(File uri){
String type = "";
String thisPath = uri.getAbsolutePath();
log.writeLog("\n\n**INFO> parsing "+thisPath);
StringBuffer thisText = new StringBuffer();
thisText.append(xmlLine); // < this contains <?xml ...?>
line.
thisText.append(dtdLine); // < This contains the
<!DOCTYPE...> line, actual DTD determined programmatically
String aLine;
FileReader f=null;
BufferedReader fis =null;
try{
f = new FileReader(uri);
fis = new BufferedReader (f);
aLine = fis.readLine();
while (aLine != null){
thisText.append(aLine);
thisText.append("\n");
aLine = fis.readLine();
}
}
catch(Exception e){
System.out.println(sourceCd+": Error reading file:
"+e.getMessage());
log.writeLog("\n**ERROR> Reading file: "+e.getMessage());
parseOK = false;
return;
}
finally{
try{
f.close();
fis.close();
f = null;
fis = null;
}
catch(IOException e){
System.out.println(sourceCd+": Can't close file:
"+e.getMessage());
log.writeLog("\n**WARNING> Can't close file: "+e.getMessage());
}
}
contentHandler = new MyContentHandler(...);
parser.setContentHandler(contentHandler);
InputSource thisInputSource = new InputSource(new
ByteArrayInputStream(thisText.toString().getBytes()));
try{
parser.parse(thisInputSource);
}
catch(et cetera...
}
CARDON Denis <[EMAIL PROTECTED]> on 08/20/2001 09:41:19 AM
Please respond to [EMAIL PROTECTED]
To: "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]>
cc: (bcc: Barry Nobel/IN/FIS)
Subject: specifying the DTD for validation with SAX
Hello,
I have a question about validation with SAX:
is it possible to specify at runtime the DTD that has to be used to perform
validation. I receive XML files from a third party and they do not specify
any DOCTYPE in the document. I have written a DTD myself to ensure that the
XML structures is OK, but I don't know how to force the SAX parser to use
it.
Adding the DOCTYPE directly into the XML file would resolve the problem, but
I'd definitly don't want to modify the XML document.
I am thinking about something like:
parser.setProperty("DTD","<root_element>","my_dtd.dtd");
I am sorry if this question has already been answered before, but I can't
check the mailing list archive: the link
(http://xml-archive.webweaving.org/xml-archive-xerces-j-user/) on the
xml.apache.org/mail.html page is dead...
Thanks a lot!
Denis
Title: specifying the DTD for validation with SAX
Hello,
I have a question about validation with SAX:
is it possible to specify at runtime the DTD that has to be used to perform validation. I receive XML files from a third party and they do not specify any DOCTYPE in the document. I have written a DTD myself to ensure that the XML structures is OK, but I don't know how to force the SAX parser to use it.
Adding the DOCTYPE directly into the XML file would resolve the problem, but I'd definitly don't want to modify the XML document.
I am thinking about something like:
parser.setProperty("DTD","<root_element>","my_dtd.dtd");
I am sorry if this question has already been answered before, but I can't check the mailing list archive: the link (http://xml-archive.webweaving.org/xml-archive-xerces-j-user/) on the xml.apache.org/mail.html page is dead...
Thanks a lot!
Denis
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
