You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/01/15 21:52:46 UTC

DO NOT REPLY [Bug 5872] New: - TransformerException does not include SAXParseException location info

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5872>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5872

TransformerException does not include SAXParseException location info

           Summary: TransformerException does not include SAXParseException
                    location info
           Product: XalanJ2
           Version: 2.1.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: javax.xml
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: nicolas@marchildon.net
                CC: nicolas@marchildon.net


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) {
        known = true;
        log4j.debug("Analysing known exception: " + t.getClass().getName());
        log4j.debug("getLocationAsString(): " + ((TransformerException)
t).getLocationAsString() + "");
        t = ((TransformerException) t).getCause();
    } 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