public static Location newLocation(DOMLocator location) {
   LocationImpl loc = new LocusTransformer().new LocationImpl();
   try {
     loc.setColumnNumber(location.getColumnNumber());
     loc.setLineNumber(location.getLineNumber());
     loc.setSystemId(location.getUri());
   } catch (Exception e) {
   }
   return loc;
 }
Ejemplo n.º 2
0
  /** Prints the error message. */
  private void printError(DOMError error) {
    int severity = error.getSeverity();
    fOut.print("[");
    if (severity == DOMError.SEVERITY_WARNING) {
      fOut.print("Warning");
    } else if (severity == DOMError.SEVERITY_ERROR) {
      fOut.print("Error");
    } else {
      fOut.print("FatalError");
      eStatus = false; // REVISIT: Abort processing if fatal error, do we need to??
    }
    fOut.print("] ");
    DOMLocator locator = error.getLocation();
    if (locator != null) {
      fOut.print(locator.getLineNumber());
      fOut.print(":");
      fOut.print(locator.getColumnNumber());
      fOut.print(":");
      fOut.print(locator.getByteOffset());
      fOut.print(",");
      fOut.print(locator.getUtf16Offset());
      Node node = locator.getRelatedNode();
      if (node != null) {
        fOut.print("[");
        fOut.print(node.getNodeName());
        fOut.print("]");
      }
      String systemId = locator.getUri();
      if (systemId != null) {
        int index = systemId.lastIndexOf('/');
        if (index != -1) systemId = systemId.substring(index + 1);
        fOut.print(": ");
        fOut.print(systemId);
      }
    }

    fOut.print(":");
    fOut.print(error.getMessage());
    fOut.println();
    fOut.flush();
  } // printError(DOMError)