javax.xml.transform.SourceLocator Java Examples
The following examples show how to use
javax.xml.transform.SourceLocator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XPath.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Tell the user of an error, and probably throw an * exception. * * @param xctxt The XPath runtime context. * @param sourceNode Not used. * @param msg An error msgkey that corresponds to one of the constants found * in {@link com.sun.org.apache.xpath.internal.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 error( XPathContext xctxt, int sourceNode, String msg, Object[] args) throws javax.xml.transform.TransformerException { String fmsg = XSLMessages.createXPATHMessage(msg, args); ErrorListener ehandler = xctxt.getErrorListener(); if (null != ehandler) { ehandler.fatalError(new TransformerException(fmsg, (SAXSourceLocator)xctxt.getSAXLocator())); } else { SourceLocator slocator = xctxt.getSAXLocator(); System.out.println(fmsg + "; file " + slocator.getSystemId() + "; line " + slocator.getLineNumber() + "; column " + slocator.getColumnNumber()); } }
Example #2
Source File: SAX2DTM.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** Retrieve the SourceLocator associated with a specific node. * This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was * set True using setProperty; if it was never set, or was set false, we * will return null. * * (We _could_ return a locator with the document's base URI and bogus * line/column information. Trying that; see the else clause.) * */ public SourceLocator getSourceLocatorFor(int node) { if (m_useSourceLocationProperty) { node = makeNodeIdentity(node); return new NodeLocator(null, m_sourceSystemId.elementAt(node), m_sourceLine.elementAt(node), m_sourceColumn.elementAt(node)); } else if(m_locator!=null) { return new NodeLocator(null,m_locator.getSystemId(),-1,-1); } else if(m_systemId!=null) { return new NodeLocator(null,m_systemId,-1,-1); } return null; }
Example #3
Source File: SourceTreeManager.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Get the source tree from the a base URL and a URL string. * * @param base The base URI to use if the urlString is relative. * @param urlString An absolute or relative URL string. * @param locator The location of the caller, for diagnostic purposes. * * @return should be a non-null reference to the node identified by the * base and urlString. * * @throws TransformerException If the URL can not resolve to a node. */ public int getSourceTree( String base, String urlString, SourceLocator locator, XPathContext xctxt) throws TransformerException { // System.out.println("getSourceTree"); try { Source source = this.resolveURI(base, urlString, locator); // System.out.println("getSourceTree - base: "+base+", urlString: "+urlString+", source: "+source.getSystemId()); return getSourceTree(source, locator, xctxt); } catch (IOException ioe) { throw new TransformerException(ioe.getMessage(), locator, ioe); } /* catch (TransformerException te) { throw new TransformerException(te.getMessage(), locator, te); }*/ }
Example #4
Source File: XPath.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Tell the user of an error, and probably throw an * exception. * * @param xctxt The XPath runtime context. * @param sourceNode Not used. * @param msg An error msgkey that corresponds to one of the constants found * in {@link com.sun.org.apache.xpath.internal.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 error( XPathContext xctxt, int sourceNode, String msg, Object[] args) throws javax.xml.transform.TransformerException { String fmsg = XSLMessages.createXPATHMessage(msg, args); ErrorListener ehandler = xctxt.getErrorListener(); if (null != ehandler) { ehandler.fatalError(new TransformerException(fmsg, (SAXSourceLocator)xctxt.getSAXLocator())); } else { SourceLocator slocator = xctxt.getSAXLocator(); System.out.println(fmsg + "; file " + slocator.getSystemId() + "; line " + slocator.getLineNumber() + "; column " + slocator.getColumnNumber()); } }
Example #5
Source File: SourceTreeManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Get the source tree from the input source. * * @param source The Source object that should identify the desired node. * @param locator The location of the caller, for diagnostic purposes. * * @return non-null reference to a node. * * @throws TransformerException if the Source argument can't be resolved to * a node. */ public int getSourceTree(Source source, SourceLocator locator, XPathContext xctxt) throws TransformerException { int n = getNode(source); if (DTM.NULL != n) return n; n = parseToNode(source, locator, xctxt); if (DTM.NULL != n) putDocumentInCache(n, source); return n; }
Example #6
Source File: SourceTreeManager.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Get the source tree from the input source. * * @param source The Source object that should identify the desired node. * @param locator The location of the caller, for diagnostic purposes. * * @return non-null reference to a node. * * @throws TransformerException if the Source argument can't be resolved to * a node. */ public int getSourceTree(Source source, SourceLocator locator, XPathContext xctxt) throws TransformerException { int n = getNode(source); if (DTM.NULL != n) return n; n = parseToNode(source, locator, xctxt); if (DTM.NULL != n) putDocumentInCache(n, source); return n; }
Example #7
Source File: NodeInfo.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * <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; }
Example #8
Source File: NodeInfo.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * <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; }
Example #9
Source File: MCRTemplatesCompiler.java From mycore with GNU General Public License v3.0 | 6 votes |
private static String buildErrorMessage(String resource, Exception cause) { StringBuilder msg = new StringBuilder("Error compiling XSL stylesheet "); msg.append(resource); if (cause instanceof TransformerException) { TransformerException tex = (TransformerException) cause; msg.append("\n").append(tex.getMessage()); SourceLocator sl = tex.getLocator(); if (sl != null) { msg.append(" (").append(sl.getSystemId()).append(") "); msg.append(" at line ").append(sl.getLineNumber()); msg.append(" column ").append(sl.getColumnNumber()); } } return msg.toString(); }
Example #10
Source File: SAX2DTM.java From Bytecoder with Apache License 2.0 | 6 votes |
/** Retrieve the SourceLocator associated with a specific node. * This is only meaningful if the XalanProperties.SOURCE_LOCATION flag was * set True using setProperty; if it was never set, or was set false, we * will return null. * * (We _could_ return a locator with the document's base URI and bogus * line/column information. Trying that; see the else clause.) * */ public SourceLocator getSourceLocatorFor(int node) { if (m_useSourceLocationProperty) { node = makeNodeIdentity(node); return new NodeLocator(null, m_sourceSystemId.elementAt(node), m_sourceLine.elementAt(node), m_sourceColumn.elementAt(node)); } else if(m_locator!=null) { return new NodeLocator(null,m_locator.getSystemId(),-1,-1); } else if(m_systemId!=null) { return new NodeLocator(null,m_systemId,-1,-1); } return null; }
Example #11
Source File: NodeInfo.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * <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; }
Example #12
Source File: NodeInfo.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * <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; }
Example #13
Source File: NodeInfo.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * <code>systemId</code> returns the system id of the node passed as * argument. If a node set is passed as argument, the system id of * the first node in the set is returned. * * @param nodeList a <code>NodeList</code> value * @return a <code>String</code> value */ public static String systemId(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.getSystemId(); else return null; }
Example #14
Source File: NodeInfo.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * <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; }
Example #15
Source File: NodeInfo.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * <code>systemId</code> returns the system id of the current * context node. * * @param context an <code>ExpressionContext</code> value * @return a <code>String</code> value */ public static String systemId(ExpressionContext context) { Node contextNode = context.getContextNode(); int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() .getSourceLocatorFor(nodeHandler); if (locator != null) return locator.getSystemId(); else return null; }
Example #16
Source File: SAXSourceLocator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * 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()); }
Example #17
Source File: NodeInfo.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * <code>publicId</code> returns the public identifier of the current * context node. * * Xalan does not currently record this value, and will return null. * * @param context an <code>ExpressionContext</code> value * @return a <code>String</code> value */ public static String publicId(ExpressionContext context) { Node contextNode = context.getContextNode(); int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() .getSourceLocatorFor(nodeHandler); if (locator != null) return locator.getPublicId(); else return null; }
Example #18
Source File: DefaultErrorHandler.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void ensureLocationSet(TransformerException exception) { // SourceLocator locator = exception.getLocator(); SourceLocator locator = null; Throwable cause = exception; // Try to find the locator closest to the cause. do { if(cause instanceof SAXParseException) { locator = new SAXSourceLocator((SAXParseException)cause); } else if (cause instanceof TransformerException) { SourceLocator causeLocator = ((TransformerException)cause).getLocator(); if(null != causeLocator) locator = causeLocator; } if(cause instanceof TransformerException) cause = ((TransformerException)cause).getCause(); else if(cause instanceof SAXException) cause = ((SAXException)cause).getException(); else cause = null; } while(null != cause); exception.setLocator(locator); }
Example #19
Source File: NodeInfo.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * <code>publicId</code> returns the public identifier of the current * context node. * * Xalan does not currently record this value, and will return null. * * @param context an <code>ExpressionContext</code> value * @return a <code>String</code> value */ public static String publicId(ExpressionContext context) { Node contextNode = context.getContextNode(); int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() .getSourceLocatorFor(nodeHandler); if (locator != null) return locator.getPublicId(); else return null; }
Example #20
Source File: DefaultErrorHandler.java From Bytecoder with Apache License 2.0 | 5 votes |
public static void ensureLocationSet(TransformerException exception) { // SourceLocator locator = exception.getLocator(); SourceLocator locator = null; Throwable cause = exception; // Try to find the locator closest to the cause. do { if(cause instanceof SAXParseException) { locator = new SAXSourceLocator((SAXParseException)cause); } else if (cause instanceof TransformerException) { SourceLocator causeLocator = ((TransformerException)cause).getLocator(); if(null != causeLocator) locator = causeLocator; } if(cause instanceof TransformerException) cause = ((TransformerException)cause).getCause(); else if(cause instanceof SAXException) cause = ((SAXException)cause).getException(); else cause = null; } while(null != cause); exception.setLocator(locator); }
Example #21
Source File: SAXSourceLocator.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * 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()); }
Example #22
Source File: NodeInfo.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * <code>systemId</code> returns the system id of the current * context node. * * @param context an <code>ExpressionContext</code> value * @return a <code>String</code> value */ public static String systemId(ExpressionContext context) { Node contextNode = context.getContextNode(); int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() .getSourceLocatorFor(nodeHandler); if (locator != null) return locator.getSystemId(); else return null; }
Example #23
Source File: DefaultErrorHandler.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void ensureLocationSet(TransformerException exception) { // SourceLocator locator = exception.getLocator(); SourceLocator locator = null; Throwable cause = exception; // Try to find the locator closest to the cause. do { if(cause instanceof SAXParseException) { locator = new SAXSourceLocator((SAXParseException)cause); } else if (cause instanceof TransformerException) { SourceLocator causeLocator = ((TransformerException)cause).getLocator(); if(null != causeLocator) locator = causeLocator; } if(cause instanceof TransformerException) cause = ((TransformerException)cause).getCause(); else if(cause instanceof SAXException) cause = ((SAXException)cause).getException(); else cause = null; } while(null != cause); exception.setLocator(locator); }
Example #24
Source File: NodeInfo.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * <code>systemId</code> returns the system id of the current * context node. * * @param context an <code>ExpressionContext</code> value * @return a <code>String</code> value */ public static String systemId(ExpressionContext context) { Node contextNode = context.getContextNode(); int nodeHandler = ((DTMNodeProxy)contextNode).getDTMNodeNumber(); SourceLocator locator = ((DTMNodeProxy)contextNode).getDTM() .getSourceLocatorFor(nodeHandler); if (locator != null) return locator.getSystemId(); else return null; }
Example #25
Source File: XPath.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Construct an XPath object. * * (Needs review -sc) This method initializes an XPathParser/ * Compiler and compiles the expression. * @param exprString The XPath expression. * @param locator The location of the expression, may be null. * @param prefixResolver A prefix resolver to use to resolve prefixes to * namespace URIs. * @param type one of {@link #SELECT} or {@link #MATCH}. * @param errorListener The error listener, or null if default should be used. * * @throws javax.xml.transform.TransformerException if syntax or other error. */ public XPath( String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type, ErrorListener errorListener, FunctionTable aTable) throws javax.xml.transform.TransformerException { m_funcTable = aTable; if(null == errorListener) errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler(); m_patternString = exprString; XPathParser parser = new XPathParser(errorListener, locator); Compiler compiler = new Compiler(errorListener, locator, m_funcTable); if (SELECT == type) parser.initXPath(compiler, exprString, prefixResolver); else if (MATCH == type) parser.initMatchPattern(compiler, exprString, prefixResolver); else throw new RuntimeException(XSLMessages.createXPATHMessage( XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, new Object[]{Integer.toString(type)})); //"Can not deal with XPath type: " + type); // System.out.println("----------------"); Expression expr = compiler.compile(0); // System.out.println("expr: "+expr); this.setExpression(expr); if((null != locator) && locator instanceof ExpressionNode) { expr.exprSetParent((ExpressionNode)locator); } }
Example #26
Source File: DTMException.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Wrap an existing exception in a DTMException. * * @param message The error or warning message, or null to * use the message from the embedded exception. * @param locator The locator object for the error or warning. * @param e Any exception */ public DTMException(String message, SourceLocator locator, Throwable e) { super(message); this.containedException = e; this.locator = locator; }
Example #27
Source File: SourceTreeManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Try to create a DOM source tree from the input source. * * @param source The Source object that identifies the source node. * @param locator The location of the caller, for diagnostic purposes. * * @return non-null reference to node identified by the source argument. * * @throws TransformerException if the source argument can not be resolved * to a source node. */ public int parseToNode(Source source, SourceLocator locator, XPathContext xctxt) throws TransformerException { try { Object xowner = xctxt.getOwnerObject(); DTM dtm; if(null != xowner && xowner instanceof com.sun.org.apache.xml.internal.dtm.DTMWSFilter) { dtm = xctxt.getDTM(source, false, (com.sun.org.apache.xml.internal.dtm.DTMWSFilter)xowner, false, true); } else { dtm = xctxt.getDTM(source, false, null, false, true); } return dtm.getDocument(); } catch (Exception e) { //e.printStackTrace(); throw new TransformerException(e.getMessage(), locator, e); } }
Example #28
Source File: XPath.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Construct an XPath object. * * (Needs review -sc) This method initializes an XPathParser/ * Compiler and compiles the expression. * @param exprString The XPath expression. * @param locator The location of the expression, may be null. * @param prefixResolver A prefix resolver to use to resolve prefixes to * namespace URIs. * @param type one of {@link #SELECT} or {@link #MATCH}. * @param errorListener The error listener, or null if default should be used. * * @throws javax.xml.transform.TransformerException if syntax or other error. */ public XPath( String exprString, SourceLocator locator, PrefixResolver prefixResolver, int type, ErrorListener errorListener) throws javax.xml.transform.TransformerException { initFunctionTable(); if(null == errorListener) errorListener = new com.sun.org.apache.xml.internal.utils.DefaultErrorHandler(); m_patternString = exprString; XPathParser parser = new XPathParser(errorListener, locator); Compiler compiler = new Compiler(errorListener, locator, m_funcTable); if (SELECT == type) parser.initXPath(compiler, exprString, prefixResolver); else if (MATCH == type) parser.initMatchPattern(compiler, exprString, prefixResolver); else throw new RuntimeException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_CANNOT_DEAL_XPATH_TYPE, new Object[]{Integer.toString(type)})); //"Can not deal with XPath type: " + type); // System.out.println("----------------"); Expression expr = compiler.compile(0); // System.out.println("expr: "+expr); this.setExpression(expr); if((null != locator) && locator instanceof ExpressionNode) { expr.exprSetParent((ExpressionNode)locator); } }
Example #29
Source File: ProcessXSLT.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void printLocation(PrintWriter diagnosticsWriter, Throwable throwable) { try { Class<?> errorHandler = Class.forName("com.sun.org.apache.xml.internal.utils.DefaultErrorHandler"); Method m = errorHandler.getMethod("printLocation", PrintWriter.class, Throwable.class); m.invoke(null, diagnosticsWriter, throwable); } catch (Throwable t) { SourceLocator locator = null; Throwable cause = throwable; // Try to find the locator closest to the cause. do { if (cause instanceof TransformerException) { SourceLocator causeLocator = ((TransformerException) cause).getLocator(); if (null != causeLocator) { locator = causeLocator; } cause = ((TransformerException) cause).getCause(); } else if (cause instanceof SAXException) { cause = ((SAXException) cause).getException(); } else { cause = cause.getCause(); } } while (null != cause); if (null != locator) { // m_pw.println("Parser fatal error: "+exception.getMessage()); String id = (null != locator.getPublicId()) ? locator.getPublicId() : (null != locator.getSystemId()) ? locator.getSystemId() : "SystemId Unknown"; //"SystemId Unknown"; diagnosticsWriter.print(id + "; " + "line: " + locator.getLineNumber() + "; column: " + locator.getColumnNumber() + "; "); } diagnosticsWriter.print("(" + throwable + ": unknown location)"); } }
Example #30
Source File: DefaultErrorHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void ensureLocationSet(TransformerException exception) { // SourceLocator locator = exception.getLocator(); SourceLocator locator = null; Throwable cause = exception; // Try to find the locator closest to the cause. do { if(cause instanceof SAXParseException) { locator = new SAXSourceLocator((SAXParseException)cause); } else if (cause instanceof TransformerException) { SourceLocator causeLocator = ((TransformerException)cause).getLocator(); if(null != causeLocator) locator = causeLocator; } if(cause instanceof TransformerException) cause = ((TransformerException)cause).getCause(); else if(cause instanceof SAXException) cause = ((SAXException)cause).getException(); else cause = null; } while(null != cause); exception.setLocator(locator); }