[ 
http://nagoya.apache.org/jira/browse/XALANJ-2010?page=comments#action_56757 ]
     
Ramprasad Kanumuru commented on XALANJ-2010:
--------------------------------------------

ErrorListener Implementation:

import java.io.FileOutputStream;
import java.io.PrintStream;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.TransformerException;

public class TransformerErrorHandler implements ErrorListener
{
  private javax.xml.transform.TransformerException transformerException = null;
  
  public TransformerErrorHandler(){
  }
  
  public void error(TransformerException exception){
    transformerException = exception;
    String exceptionType = "Error";
    printMessage(exception,exceptionType);
  }
           
  public void fatalError(TransformerException exception){
    transformerException = exception;
    String exceptionType = "fatalError";
    printMessage(exception,exceptionType);
  }
                
  public void warning (TransformerException exception){
   transformerException = exception;
   String exceptionType = "warning";
   printMessage(exception,exceptionType);
  }
           
  private void printMessage(javax.xml.transform.TransformerException 
exception,String exceptionType)
  {
      try{
        FileOutputStream fos = new FileOutputStream("D:\\temp\\MapTest.log");
        PrintStream printStream = new PrintStream(fos);
        printStream.println("Printing Transformer Exception 
Type::"+exceptionType+"\n");
        String message = "";
        message = exception.getMessage();
        if(message != null)
        {
           String[] messages = message.split(":");
           if(messages != null && messages.length > 0)
           {
             message = messages[messages.length-1];
           }
        }
        printStream.println("The Message::"+message);
        printStream.println(exception.getMessageAndLocation());
        exception.printStackTrace(printStream);
        printStream.close();
        fos.close();
    }catch(Exception exx)
    {
        
    }
  }
  
  public TransformerException getTransformerException(){
    return transformerException;
  }
  
}

> getMessageAndLocation() api of TransformerException return stack trace along 
> with the error message
> ---------------------------------------------------------------------------------------------------
>
>          Key: XALANJ-2010
>          URL: http://nagoya.apache.org/jira/browse/XALANJ-2010
>      Project: XalanJ2
>         Type: Bug
>   Components: JAXP
>     Versions: 2.5
>  Environment: Microsoft Windows 2000
>     Reporter: Ramprasad Kanumuru

>
> The api getMessageAndLocation() in the class TransformerException is 
> returning the stack trace of the exception along with the exception message. 
> Also, the location information is missing.
> Exception message returned:
> javax.xml.transform.TransformerConfigurationException: 
> javax.xml.transform.TransformerException: 
> javax.xml.transform.TransformerException: Empty expression!
> -----------------------------  Sample XSL file 
> --------------------------------------
> <xsl:stylesheet version="1.0"
>                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>                 xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>                 exclude-result-prefixes="xsl xsd">
>   <xsl:template match="/">
>     <PO>
>       <date>
>         <xsl:value-of select="/invoice/date"/>
>       </date>
>       <supplier>
>         <name>
>           <xsl:value-of select="/invoice/seller/NAME"/>
>         </name>
>         <address>
>           <street>
>             <xsl:value-of select="/invoice/seller/BillAddressTo/street2"/>
>           </street>
>           <city>
>             <xsl:value-of select="/invoice/seller/BillAddressTo/city"/>
>           </city>
>           <zip>
>             <xsl:value-of select="/invoice/seller/BillAddressTo/pin"/>
>           </zip>
>           <state>
>             <xsl:value-of select="/invoice/seller/BillAddressTo/state"/>
>           </state>
>           <streetNext>
>             <xsl:value-of select="/invoice/seller/BillAddressTo/street1"/>
>           </streetNext>
>         </address>
>         <uid>
>           <xsl:value-of select="/invoice/seller/id"/>
>         </uid>
>       </supplier>
>       <buyer>
>         <name>
>           <xsl:value-of select="/invoice/purchaser/NAME"/>
>         </name>
>         <address>
>           <street>
>             <xsl:value-of select="/invoice/purchaser/address/street2"/>
>           </street>
>           <city>
>             <xsl:value-of select="/invoice/purchaser/address/city"/>
>           </city>
>           <xsl:if test="">
>             <zip>
>               <xsl:value-of select="/invoice/purchaser/address/pin"/>
>             </zip>
>           </xsl:if>
>           <state>
>             <xsl:value-of select="/invoice/purchaser/address/state"/>
>           </state>
>           <streetNext>
>             <xsl:value-of select="/invoice/purchaser/address/street1"/>
>           </streetNext>
>         </address>
>         <uid>
>           <xsl:value-of select="/invoice/purchaser/uid"/>
>         </uid>
>       </buyer>
>     </PO>
>   </xsl:template>
> </xsl:stylesheet>
> -------------------------------End of XSL ----------------------------------
> --------------------- Instance XML -----------------------------------
> <?xml version="1.0" encoding="windows-1252"?>
> <invoice>
>    <date>2004-12-08T12:24:26.630</date>
>    <purchaser>
>       <NAME>NAME48</NAME>
>       <address>
>          <street1>street149</street1>
>          <street2>street250</street2>
>          <city>city51</city>
>          <pin>pin52</pin>
>          <country>country53</country>
>          <state>state54</state>
>       </address>
>       <uid>uid55</uid>
>    </purchaser>
>    <seller>
>       <NAME>NAME56</NAME>
>       <BillAddressTo>
>          <street1>street157</street1>
>          <street2>street258</street2>
>          <city>city59</city>
>          <pin>pin60</pin>
>          <country>country61</country>
>          <state>state62</state>
>       </BillAddressTo>
>       <id>id63</id>
>    </seller>
>    <line-item>
>       <description>description64</description>
>       <LinePrice>65</LinePrice>
>       <QtyOrdered>66</QtyOrdered>
>       <line-total>67</line-total>
>       <id>id68</id>
>    </line-item>
>    <line-item>
>       <description>description69</description>
>       <LinePrice>70</LinePrice>
>       <QtyOrdered>71</QtyOrdered>
>       <line-total>72</line-total>
>       <id>id73</id>
>    </line-item>
>    <line-item>
>       <description>description74</description>
>       <LinePrice>75</LinePrice>
>       <QtyOrdered>76</QtyOrdered>
>       <line-total>77</line-total>
>       <id>id78</id>
>    </line-item>
>    <line-item>
>       <description>description79</description>
>       <LinePrice>80</LinePrice>
>       <QtyOrdered>81</QtyOrdered>
>       <line-total>82</line-total>
>       <id>id83</id>
>    </line-item>
>    <line-item>
>       <description>description84</description>
>       <LinePrice>85</LinePrice>
>       <QtyOrdered>86</QtyOrdered>
>       <line-total>87</line-total>
>       <id>id88</id>
>    </line-item>
>    <line-item>
>       <description>description89</description>
>       <LinePrice>90</LinePrice>
>       <QtyOrdered>91</QtyOrdered>
>       <line-total>92</line-total>
>       <id>id93</id>
>    </line-item>
>    <total>94</total>
> </invoice>
> -------------------- End Instance XML 
> -----------------------------------------

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to