Package org.xml.sax

Examples of org.xml.sax.ErrorHandler


        } catch (ParserConfigurationException e) {
            LOG.log(Level.SEVERE, "Unable to create a document builder, e");
            throw new RuntimeException("Unable to create a document builder, e");
        }
        org.w3c.dom.Document doc;
        documentBuilder.setErrorHandler(new ErrorHandler() {

            private String errorMessage(SAXParseException exception) {
                return MessageFormat.format("{0} at {1} line {2} column {3}.",
                                            new Object[] {exception.getMessage(), path,
                                                          Integer.valueOf(exception.getLineNumber()),
View Full Code Here


   * @param mediaTypeString
   *      - media type of stream. If unknown null can be used.
   */
  protected OdfSchemaDocument(OdfPackage pkg, String internalPath, String mediaTypeString) {
    super(pkg, internalPath, mediaTypeString);
    ErrorHandler errorHandler = pkg.getErrorHandler();
    if (errorHandler != null) {
      if (pkg.getFileEntry(internalPath + "content.xml") == null && pkg.getFileEntry(internalPath + "styles.xml") == null) {
        try {
          String baseURI = pkg.getBaseURI();
          if (baseURI == null) {
            baseURI = internalPath;
          } else {
            if (!internalPath.equals(ROOT_DOCUMENT_PATH)) {
              baseURI = "/" + internalPath;
            }
          }
          errorHandler.error(new OdfValidationException(OdfSchemaConstraint.DOCUMENT_WITHOUT_CONTENT_NOR_STYLES_XML, baseURI));
        } catch (SAXException ex) {
          Logger.getLogger(OdfPackage.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
      InputStream mimetypeStream = pkg.getInputStream(OdfPackage.OdfFile.MEDIA_TYPE.getPath(), true);
      if (internalPath.equals(ROOT_DOCUMENT_PATH) && mimetypeStream == null) {
        try {
          errorHandler.error(new OdfValidationException(OdfSchemaConstraint.PACKAGE_SHALL_CONTAIN_MIMETYPE, pkg.getBaseURI()));
        } catch (SAXException ex) {
          Logger.getLogger(OdfPackage.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    }
View Full Code Here

    return firstEntryName;
  }

  private void addZipEntry(ZipEntry zipEntry, Map<String, ZipEntry> zipEntries) {
    String filePath = OdfPackage.normalizePath(zipEntry.getName());
    ErrorHandler errorHandler = mPackage.getErrorHandler();
    if (errorHandler != null) {
      try {
        int zipMethod = zipEntry.getMethod();
        if (zipMethod != ZipEntry.STORED && zipMethod != ZipEntry.DEFLATED) {
          mPackage.getErrorHandler().error(new OdfValidationException(OdfPackageConstraint.PACKAGE_ENTRY_USING_INVALID_COMPRESSION, mPackage.getBaseURI(), filePath));
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 {
            }
            public void fatalError(SAXParseException exception) throws SAXException {
View Full Code Here

       
        if ("".equals(result.getBaseURI())) {
            result.setBaseURI(in.getSystemId());
        }
       
        ErrorHandler errorHandler = parser.getErrorHandler();
        if (errorHandler instanceof ValidityRequired) {
            ValidityRequired validityHandler
              = (ValidityRequired) errorHandler;
            if (!validityHandler.isValid())  {
                ValidityException vex = validityHandler.vexception;
View Full Code Here

     */
    public MarinerDigester(XMLReader reader) {
        super(reader);
        // Ensure we fail on errors;
        // Note that errors are logged by Digester already.
        setErrorHandler(new ErrorHandler() {
            public void warning(SAXParseException e) throws SAXException {
            }

            public void error(SAXParseException e) throws SAXException {
                throw e;
View Full Code Here

            boolean failOnWarningsAndLog) {
        this.delegate = delegate;

        // Create a collating error handler, or a simple error throwing one
        // based on the flag.
        ErrorHandler handler;
        if (failOnWarningsAndLog) {
            collatingErrorHandler = new CollatingErrorHandler();
            handler = collatingErrorHandler;
        } else {
            collatingErrorHandler = null;
            handler = new ErrorHandler() {
                public void warning(SAXParseException e) {
                }

                public void error(SAXParseException e) throws SAXException {
                    throw e;
View Full Code Here

        SAXBuilder builder = new SAXBuilder();
        Document doc;

        // This error handler quietly consumes all errors
        ErrorHandler errorHandler = new ErrorHandler() {
            public void warning(SAXParseException e) throws SAXException {
                System.out.println("Warning reported: " + e);
                e.printStackTrace(System.out);
            }
View Full Code Here

                builder = factory.newDocumentBuilder();
            } catch (ParserConfigurationException e) {
                throw new Error(e);
            }

            builder.setErrorHandler(new ErrorHandler() {
                public void warning(SAXParseException e) throws SAXException {
                    throw e;
                }

                public void error(SAXParseException e) throws SAXException {
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.