Details
-
Bug
-
Status: Resolved
-
Resolution: Fixed
-
2.1.0
-
None
-
None
-
Operating System: Linux
Platform: PC
-
5872
Description
When creating a Transformer from TransformerFactory.newInstance() by passing a
StreamSource of XSLT, a TransformerException is thrown, but does not include any
location information.
By exploring the TransformerException using this bit of code, I saw there was a
SAXParseException that contained location information:
boolean known = true;
while (known && (t != null)) {
if (t instanceof TransformerException)
else if (t instanceof org.xml.sax.SAXParseException)
{ known = true; log4j.debug("Analysing known exception: " + t.getClass().getName()); int col = ((org.xml.sax.SAXParseException) t).getColumnNumber(); int line = ((org.xml.sax.SAXParseException) t).getLineNumber(); log4j.debug("Location: Col=" + col + ", line=" + line); t = ((org.xml.sax.SAXParseException) t).getException(); }else
{ log4j.debug("Unknown cause: " + t.getClass().getName()); known = false; }}
Note: If you don't use log4j, replace "log4j.debug" by "System.out.println", for
example.
The result of this exploration gives:
Analysing known exception: javax.xml.transform.TransformerConfigurationException
getLocationAsString(): null
Analysing known exception: javax.xml.transform.TransformerConfigurationException
getLocationAsString(): null
Analysing known exception: javax.xml.transform.TransformerException
getLocationAsString(): null
Analysing known exception: org.xml.sax.SAXParseException
Location: Col=76, line=85