这个XML没有问题啊?你的程序?

解决方案 »

  1.   

    以下是我写的程序。处理xml解析的。也不会有什么问题呀!
        String strCurPath = System.getProperty("user.dir");
        String strSchema = strCurPath + "\\TestPaper.xsd";
        java.io.File f = new java.io.File(strSchema);
        try {
          parser.setFeature( "http://xml.org/sax/features/validation", true );
          parser.setFeature( "http://apache.org/xml/features/validation/schema", true);
          parser.setFeature( "http://apache.org/xml/features/validation/schema-full-checking", true);
          parser.setExternalNoNamespaceSchemaLocation2(strSchema);
          parser.parse(uri);
        }
        catch(Exception e) {
          e.printStackTrace();
          fSuccess = false;
        }
        if ( fSuccess ) {
          System.out.println("合法");
        }
        else {
         System.out.println("非法");
        }    return fSuccess;
      }  public void warning(SAXParseException exception) throws SAXException {
        fSuccess = false;
         System.out.println("警告"+exception);
      }  public void error(SAXParseException exception) throws SAXException {
        fSuccess = false;
         System.out.println("错误"+exception);
     }  public void fatalError(SAXParseException exception) throws SAXException {
        fSuccess = false;
         System.out.println("致命错误"+exception);
      }
      

  2.   

    程序有问题?
    Sorry,把parser忘定义了。
    private MyParser parser = new MyParser();
    class MyParser extends DOMParser {
      public MyParser() {
      }
      public void setExternalNoNamespaceSchemaLocation2(String value)
          throws SAXNotRecognizedException, SAXNotSupportedException {
        this.setExternalNoNamespaceSchemaLocation(value);
      }
    }