以文本方式查看主题

-  W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL  (http://bbs.xml.org.cn/index.asp)
--  『 DOM/SAX/XPath 』  (http://bbs.xml.org.cn/list.asp?boardid=11)
----  小女子拜求了!程序运行后出现System property org.xml.sax.driver not specified,无法debug![讨论]  (http://bbs.xml.org.cn/dispbbs.asp?boardid=11&rootid=&id=13327)


--  作者:ayanamiy
--  发布时间:1/7/2005 2:55:00 AM

--  小女子拜求了!程序运行后出现System property org.xml.sax.driver not specified,无法debug![讨论]
在BlueJ里compile,没有syntax error,但是运行却显示如下错误信息.
org.xml.sax.SAXException: System property org.xml.sax.driver not specified

程序目的:
从一个xml file读取相关信息,然后输出结果并生成新的xml file. 采用SAX Version 2,

怀疑问题出在这部分代码里:
import java.io.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;

public class bookSAXApp extends DefaultHandler
{
  ............

public static void main (String args[]) throws Exception
  {
      try {
                XMLReader saxParser= XMLReaderFactory.createXMLReader();//creating an xml reader        

               bookSAXApp handler = new bookSAXApp();   
               saxParser.setContentHandler(handler);
              saxParser.setErrorHandler(handler);

            FileReader reader = new FileReader("bookInstance.xml");
           saxParser.parse( new InputSource(reader));
                
         PrintWriter toFile=new PrintWriter(new FileWriter("interBooks.xml"));
         toFile.println(xmlContent);
         toFile.close();
      }
      catch ( SAXParseException spe ) {
         System.err.println( "Parse Error: " + spe.getMessage() );
      }
    
      catch ( SAXException se ) {
         se.printStackTrace();
      }
      catch ( IOException e ) {
         e.printStackTrace();
      }
   
    }    


--  作者:xhaopuj
--  发布时间:5/13/2005 10:06:00 AM

--  
Specify it on command line when you run java, or put it in a property file and make sure load it into your jvm:

    * -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser if you're use xerces.
      Alternatives:

-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl

    * -Dorg.xml.sax.driver=org.apache.crimson.parser.XMLReaderImpl if you're use crimson.
    * Make sure xerces.jar or crimson.jar or something similar on your classpath

BTW, you can specify Transformer too the same fashion.

    * javax.xml.transform.TransformerFactory = org.apache.xalan.processor.TransformerFactoryImpl if you're using xalan
    * javax.xml.transform.TransformerFactory = com.icl.saxon.TransformerFactoryImpl if you're using saxon
    * Make sure xalan.jar or saxon.jar or something similar on your classpath


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms