Hi all,
I'm using JDK1.1.8 because I also use the JAVA/Corba toolkit for Lotus Domino which needs JDK1.1.8.
I want to read some config xml files using the sax2 implementation. For example I'm trying to read the following files:
dtd: (config.dtd)
<!ELEMENT NotesStarterConfig (User, Starter*)>
<!ATTLIST User
name CDATA #REQUIRED
password CDATA #REQUIRED
>
<!ELEMENT Starter (Host, Database, View)>
<!ELEMENT User EMPTY>
<!ELEMENT Host (#PCDATA)>
<!ELEMENT Database (#PCDATA)>
<!ELEMENT View (#PCDATA)>
xml:(config.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE NotesStarterConfig SYSTEM "config.dtd">
<NotesStarterConfig>
<User name="Harm de Laat" password="mypassword"/>
<Starter>
<Host>NotesServer5</Host>
<Database>deRegionale/prodord.nsf</Database>
<View>photoconversion</View>
</Starters>
</NotesStarterConfig>
I do that using the following code:
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;
import org.xml.sax.ErrorHandler;
public class NotesStarter {
public static void main (String args[]) {
new NotesStarter();
}
public NotesStarter() {
try {
XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
parser.setContentHandler(new SimpleContentHandler());
parser.parse("config.xml");
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
class SimpleContentHandler extends org.xml.sax.helpers.DefaultHandler {
public void startDocument() throws SAXException {
System.out.println("Start of document");
}
public void startElement(String namespaceURI,
String localName,
String qname,
Attributes atts) throws SAXException {
System.out.println("Found element: " + localName);
}
public void endDocument() throws SAXException {
System.out.println("Done parsing...");
}
}
}
I have trouble running this program. Because after the "Start of document" print in startDocument() my application hangs...
I can only stop the program by pressing Ctrl-C of kill it with BaSH.
I'm using IBM's implementation of Java 1.1.8. My platform is Redhat 7.2. I have set the following environment variables:
PATH=/usr/java/jakarta-ant-1.4.1/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/harm/bin:/usr/jdk118/bin/
CLASSPATH=/usr/java:/usr/java/mm.mysql-2.0.4/mysql.jar:/usr/java/javamail-1.2/mail.jar:/usr/java/xerces-2_0_0/xercesImpl.jar:/usr/java/xerces-2_0_0/xmlParserAPIs.jar:/usr/local/lib/jmagick.jar:.
JAVA_HOME=/usr/jdk118/
LD_ASSUME_KERNEL=2.2.5
The LD_ASSUME_KERNEL is required because javac will not work without it on a 2.4.x kernel....
I know that when I remove the DOCTYPE statement in the xml-file the parsing does work! (But I realy need validation).
Can someone please help?
Many Thanks,
Harm de Laat
Informatiefabriek
The Netherlands
