/**
  * Try to create a Location from inparam Exception, return null if inparam is not successfully
  * transformed.
  */
 public static Location newLocation(Exception e) {
   if (e instanceof SAXParseException) {
     return LocusTransformer.newLocation((SAXParseException) e);
   } else if (e instanceof CSSParseException) {
     return LocusTransformer.newLocation((CSSParseException) e);
   } else if (e instanceof FilesetFileException) {
     return LocusTransformer.newLocation((FilesetFileException) e);
   } else if (e instanceof TransformerException) {
     return LocusTransformer.newLocation((TransformerException) e);
   }
   return null;
 }
  public static Location newLocation(FilesetFileException ffe) {
    LocationImpl loc = new LocusTransformer().new LocationImpl();
    try {
      Throwable cause = ffe.getRootCause();
      if (cause == null) cause = ffe.getCause();

      Location innerLocation = null;
      if (cause instanceof CSSParseException) {
        innerLocation = LocusTransformer.newLocation((CSSParseException) cause);
      } else if (cause instanceof SAXParseException) {
        innerLocation = LocusTransformer.newLocation((SAXParseException) cause);
      }

      loc.setSystemId(ffe.getOrigin().getFile().toURI().toString());
      if (innerLocation != null) {
        loc.setLineNumber(innerLocation.getLineNumber());
        loc.setColumnNumber(innerLocation.getColumnNumber());
      }
    } catch (Exception e) {
    }

    return loc;
  }
Exemplo n.º 3
0
 /*
  * (non-Javadoc)
  * @see org.w3c.dom.DOMErrorHandler#handleError(org.w3c.dom.DOMError)
  */
 public boolean handleError(DOMError error) {
   Location loc = LocusTransformer.newLocation(error.getLocation());
   MessageEvent.Type type = null;
   if (error.getSeverity() == DOMError.SEVERITY_WARNING) {
     type = MessageEvent.Type.WARNING;
   } else {
     type = MessageEvent.Type.ERROR;
   }
   this.sendMessage(error.getMessage(), type, MessageEvent.Cause.INPUT, loc);
   if (error.getSeverity() == DOMError.SEVERITY_WARNING) {
     return true;
   }
   return false;
 }