Refine search
/** * Warn the user of an problem. * * @param msg An error msgkey that corresponds to one of the constants found * in {@link org.apache.xpath.res.XPATHErrorResources}, which is * a key for a format string. * @param args An array of arguments represented in the format string, which * may be null. * * @throws TransformerException if the current ErrorListoner determines to * throw an exception. */ public void warn(String msg, Object[] args) throws TransformerException { java.lang.String fmsg = XSLMessages.createXPATHWarning(msg, args); if (null != m_errorHandler) { m_errorHandler.warning(new TransformerException(fmsg, m_locator)); } else { System.out.println(fmsg +"; file "+m_locator.getSystemId() +"; line "+m_locator.getLineNumber() +"; column "+m_locator.getColumnNumber()); } }
/** * Constructor SAXSourceLocator * * * @param locator Source locator */ public SAXSourceLocator(javax.xml.transform.SourceLocator locator) { m_locator = null; this.setColumnNumber(locator.getColumnNumber()); this.setLineNumber(locator.getLineNumber()); this.setPublicId(locator.getPublicId()); this.setSystemId(locator.getSystemId()); }
/** * Set the location information for this element. * * @param locator Source Locator with location information for this element */ public void setLocaterInfo(SourceLocator locator) { m_lineNumber = locator.getLineNumber(); m_columnNumber = locator.getColumnNumber(); }
/** * Set the location information for this element. * * @param locator SourceLocator holding location information */ public void setLocaterInfo(SourceLocator locator) { m_publicId = locator.getPublicId(); m_systemId = locator.getSystemId(); super.setLocaterInfo(locator); }
public void fatalError( final TransformerException e ) throws TransformerException { throw new TransformerException( DefaultModelBundle.getInstance(). getParseExceptionMessage( Locale.getDefault(), rsrc.toExternalForm(), e.getMessage(), new Integer( e.getLocator().getLineNumber() ), new Integer( e.getLocator().getColumnNumber() ) ), e ); }
private String getMessage(TransformerException exception) { SourceLocator locator = exception.getLocator(); if (locator != null) { String id = (!locator.getPublicId().equals(locator.getPublicId())) ? locator.getPublicId() : (null != locator.getSystemId()) ? locator.getSystemId() : "SystemId Unknown"; return "File " + id + "; Line " + locator.getLineNumber() + "; Column " + locator.getColumnNumber() + "; " + exception.getMessage(); } return exception.getMessage(); } }
final SourceLocator locator = e.getLocator(); if (locator != null) { final String systemid = locator.getSystemId(); if (systemid != null) { String url = systemid; msg.append("Unknown file"); final int line = locator.getLineNumber(); if (line != -1) { msg.append(":"); msg.append(line); final int column = locator.getColumnNumber(); if (column != -1) { msg.append(":"); msg.append(type); msg.append("! "); msg.append(e.getMessage()); if (e.getCause() != null) { msg.append(" Cause: "); msg.append(e.getCause());
throw new TransformerException(ioe.getMessage(), (SourceLocator)xctxt.getSAXLocator(), ioe); throw new TransformerException(te); throw new TransformerException(ioe.getMessage(), (SourceLocator)xctxt.getSAXLocator(), ioe); SourceLocator locator = spe2.getLocator(); if ((null != locator) && (null != locator.getSystemId())) diagnosticsWriter.println(" ID: " + locator.getSystemId() + " Line #" + locator.getLineNumber() + " Column #" + locator.getColumnNumber()); e = spe2.getException();
private void log(final TransformerException e, final String errorType, final Level level, final boolean rethrow) throws TransformerException { if (this.logger.isLoggable(Level.FINE)) { this.logger.log(Level.FINE, this.logPrefix, e); } else if (this.logger.isLoggable(level)) { int line = -1; final SourceLocator locator = e.getLocator(); if (locator != null) line = locator.getLineNumber(); String msg = errorType + " was found: " + e.getMessage() + " (line: " + ((line == -1) ? "unresolved" : line) + ")."; this.logger.log(level, this.logPrefix + msg); } if (rethrow) { throw e; } } }
SourceLocator causeLocator = ((TransformerException)cause).getLocator(); if(null != causeLocator) locator = causeLocator; cause = ((TransformerException)cause).getCause(); else if(cause instanceof WrappedRuntimeException) cause = ((WrappedRuntimeException)cause).getException(); String id = (null != locator.getPublicId() ) ? locator.getPublicId() : (null != locator.getSystemId()) ? locator.getSystemId() : XMLMessages.createXMLMessage(XMLErrorResources.ER_SYSTEMID_UNKNOWN, null); //"SystemId Unknown"; pw.print(id + "; " +XMLMessages.createXMLMessage("line", null) + locator.getLineNumber() + "; " +XMLMessages.createXMLMessage("column", null) + locator.getColumnNumber()+"; ");
/** * Get the location information as a string. * * @return A string with location info, or null * if there is no location information. */ public String getLocationAsString() { if (null != locator) { StringBuilder sbuffer = new StringBuilder(); String systemID = locator.getSystemId(); int line = locator.getLineNumber(); int column = locator.getColumnNumber(); if (null != systemID) { sbuffer.append("; SystemID: "); sbuffer.append(systemID); } if (0 != line) { sbuffer.append("; Line#: "); sbuffer.append(line); } if (0 != column) { sbuffer.append("; Column#: "); sbuffer.append(column); } return sbuffer.toString(); } else { return null; } }
private RuntimeException handleError( final TransformerException e ) { final SourceLocator locator = e.getLocator(); final String systemId = locator != null ? locator.getSystemId() : null; if ( systemId != null ) { return ResourceProblemException.create(). lineNumber( locator.getLineNumber() ). resource( toResourceKey( systemId ) ). cause( e ). message( e.getMessage() ). build(); } return Throwables.propagate( e ); }
@Nonnull private static IResourceError _buildError (@Nonnull final TransformerException ex, @Nonnull final EErrorLevel eErrorLevel, @Nonnull final IHasDisplayText aErrorMsg) { final SourceLocator aLocator = ex.getLocator (); final IResourceLocation aLocation = aLocator != null ? new ResourceLocation (StringHelper.getConcatenatedOnDemand (aLocator.getPublicId (), "/", aLocator.getSystemId ()), aLocator.getLineNumber (), aLocator.getColumnNumber ()) : new ResourceLocation (ex.getLocationAsString ()); return new ResourceError (aLocation, eErrorLevel, aErrorMsg, ex); }
/** * Return the base identifier. * * @return The base identifier of the current stylesheet. */ public String getBaseIdentifier() { // Try to get the baseIdentifier from the baseIdentifier's stack, // which may not be the same thing as the value found in the // SourceLocators stack. String base = (String) (m_baseIdentifiers.isEmpty() ? null : m_baseIdentifiers.peek()); // Otherwise try the stylesheet. if (null == base) { SourceLocator locator = getLocator(); base = (null == locator) ? "" : locator.getSystemId(); } return base; }
public void notifyListener(String label, Sequence<?> val, SourceLocator loc, XPathContext context) { InstructionDetails info = new InstructionDetails(); info.setConstructType(LocationKind.TRACE_CALL); info.setLineNumber(loc.getLineNumber()); info.setSystemId(loc.getSystemId()); info.setProperty("label", label); info.setProperty("value", val); TraceListener listener = context.getController().getTraceListener(); listener.enter(info, context); listener.leave(info); }
/** * <code>publicId</code> returns the public identifier of the node passed as * argument. If a node set is passed as argument, the public identifier of * the first node in the set is returned. * * Xalan does not currently record this value, and will return null. * * @param nodeList a <code>NodeList</code> value * @return a <code>String</code> value */ public static String publicId(NodeList nodeList) { if (nodeList == null || nodeList.getLength() == 0) return null; Node node = nodeList.item(0); int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); SourceLocator locator = ((DTMNodeProxy)node).getDTM() .getSourceLocatorFor(nodeHandler); if (locator != null) return locator.getPublicId(); else return null; }
/** * <code>lineNumber</code> returns the line number of the node * passed as argument. If a node set is passed as argument, the line * number of the first node in the set is returned. * * NOTE: Xalan does not normally record location information for each node. * To obtain it, you must set the custom TrAX attribute * "http://xml.apache.org/xalan/features/source_location" * true in the TransformerFactory before generating the Transformer and executing * the stylesheet. Storage cost per node will be noticably increased in this mode. * * @param nodeList a <code>NodeList</code> value * @return an <code>int</code> value. This may be -1 to indicate that the * line number is not known. */ public static int lineNumber(NodeList nodeList) { if (nodeList == null || nodeList.getLength() == 0) return -1; Node node = nodeList.item(0); int nodeHandler = ((DTMNodeProxy)node).getDTMNodeNumber(); SourceLocator locator = ((DTMNodeProxy)node).getDTM() .getSourceLocatorFor(nodeHandler); if (locator != null) return locator.getLineNumber(); else return -1; }
return locator.getColumnNumber(); else return -1;
public void error( final TransformerException e ) throws TransformerException { throw new TransformerException( DefaultModelBundle.getInstance(). getParseExceptionMessage( Locale.getDefault(), rsrc.toExternalForm(), e.getMessage(), new Integer( e.getLocator().getLineNumber() ), new Integer( e.getLocator().getColumnNumber() ) ), e ); }
SAXParseException transform(TransformerException exception) throws TransformerException { Throwable cause = exception.getException(); // Xalan takes it upon itself to catch exceptions and pass them to the ErrorListener. if (cause instanceof RuntimeException) throw (RuntimeException)cause; if (cause instanceof SAXException || cause instanceof IncorrectSchemaException || cause instanceof IOException) throw exception; SourceLocator locator = exception.getLocator(); if (locator == null) return new SAXParseException(exception.getMessage(), null); // Xalan sometimes loses the mainSystemId; work around this. String s = locator.getSystemId(); if (s == null) s = systemId; return new SAXParseException(exception.getMessage(), locator.getPublicId(), s, locator.getLineNumber(), locator.getColumnNumber()); } }