Package org.xml.sax

Examples of org.xml.sax.ErrorHandler


    return false;
  }

    protected Document parse(File artifact) throws Exception {
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setErrorHandler(new ErrorHandler() {
            public void warning(SAXParseException exception) throws SAXException {
            }
            public void error(SAXParseException exception) throws SAXException {
            }
            public void fatalError(SAXParseException exception) throws SAXException {
View Full Code Here


    // It wasn't in the cache, so create a parser to parse the file.  We only
    // deal with correct files, so turn on validation and install an error
    // handler that will throw an exception.
    profiles = new ArrayList();
    DOMParser parser = XML.createDOMParser();
    parser.setErrorHandler(new ErrorHandler() {
      public void error(SAXParseException ex) throws SAXParseException {
        System.err.println("Parse error line " + ex.getLineNumber() + " column "
          + ex.getColumnNumber() + ": " + ex.getMessage());
        throw ex;
      }
View Full Code Here

        if (dbf == null) {
            dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
        }
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setErrorHandler(new ErrorHandler() {
            public void warning(SAXParseException exception) throws SAXException {
            }
            public void error(SAXParseException exception) throws SAXException {
            }
            public void fatalError(SAXParseException exception) throws SAXException {
View Full Code Here

     *         has been registered.
     * @see #setErrorHandler
     */
    public ErrorHandler getErrorHandler() {

        ErrorHandler errorHandler = null;
        try {
            XMLErrorHandler xmlErrorHandler =
                (XMLErrorHandler)fConfiguration.getProperty(ERROR_HANDLER);
            if (xmlErrorHandler != null &&
                xmlErrorHandler instanceof ErrorHandlerWrapper) {
View Full Code Here

        if (dbf == null) {
            dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
        }
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setErrorHandler(new ErrorHandler() {
            public void warning(SAXParseException exception) throws SAXException {
            }
            public void error(SAXParseException exception) throws SAXException {
            }
            public void fatalError(SAXParseException exception) throws SAXException {
View Full Code Here

        return false;
    }

    protected Document parse(File artifact) throws Exception {
        DocumentBuilder db = dbf.newDocumentBuilder();
        db.setErrorHandler(new ErrorHandler() {
            public void warning(SAXParseException exception) throws SAXException {
            }

            public void error(SAXParseException exception) throws SAXException {
            }
View Full Code Here

        }
       
        // These validation errors are just warnings for us as we want to support
        // running from an XML document with XSD validation errors, as long as we can
        // get the metadata we need from the document
        handler.setErrorHandler(new ErrorHandler() {         
            private String getMessage(SAXParseException e) {
                return "XMLSchema validation problem in: " + e.getSystemId() + ", line: " + e.getLineNumber() + ", column: " + e.getColumnNumber() + "\n" + e.getMessage();
            }
           
            public void error(SAXParseException exception) throws SAXException {             
View Full Code Here

        //factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
        //factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", SchemaUrl);
        DocumentBuilder builder = factory.newDocumentBuilder();
        if (validate) {
            LocalResolver lr = new LocalResolver(new DefaultHandler());
            ErrorHandler eh = new LocalErrorHandler(docDescription, lr);

            builder.setEntityResolver(lr);
            builder.setErrorHandler(eh);
        }
        document = builder.parse(is);
View Full Code Here

    SAXParser sp = spf.newSAXParser();
    if (pValidating) {
      sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
    }
    XMLReader xr = sp.getXMLReader();
    xr.setErrorHandler(new ErrorHandler(){
      public void error(SAXParseException e) throws SAXException { throw e; }
      public void fatalError(SAXParseException fe) throws SAXException { throw fe; }
      public void warning(SAXParseException w) throws SAXException { throw w; }
    });
    return xr;
View Full Code Here

      throw new IllegalArgumentException("Given internalPath '" + internalPath
          + "' is an illegal or inappropriate argument.");
    }
    OdfMediaType odfMediaType = OdfMediaType.getOdfMediaType(documentMediaType);
    if (odfMediaType == null) {
      ErrorHandler errorHandler = odfPackage.getErrorHandler();
      Matcher matcherCTRL = CONTROL_CHAR_PATTERN.matcher(documentMediaType);
      if (matcherCTRL.find()) {
        documentMediaType = matcherCTRL.replaceAll(EMPTY_STRING);
      }
      OdfValidationException ve = new OdfValidationException(OdfSchemaConstraint.DOCUMENT_WITHOUT_ODF_MIMETYPE,
          internalPath, documentMediaType);
      if (errorHandler != null) {
        errorHandler.fatalError(ve);
      }
      throw ve;
    }
    return newDocument(odfPackage, internalPath, odfMediaType);
  }
View Full Code Here

TOP

Related Classes of org.xml.sax.ErrorHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.