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

Hi ,

Thanks for looking into the issue. I am inlining the java code that
I used to execute the xsl. The output generated is:

Output Generated by getMessageAndLocation()
-----------------------------------------------------------------------
javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException:
javax.xml.transform.TransformerException: Empty expression!

Output Generated by getLocationAsString()
---------------------------------------------------------------
null

Ideally I want the getMessageAndLocation() to generate
; Line#: 68; Column#: 27 : Empty expression!


This error message would allow me to easily locate the problem, in this
case the 'if' construct without any expression ( <xsl:if test="">)

I believe the user will not be interested in the java exception stack
trace and it does not seem to be intuitive to show stack trace in the exception 
message. Please correct me if I am wrong.

Thanks,
Ramprasad

import java.io.FileInputStream;
import java.io.FileOutputStream;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class TransformerTest
{
public TransformerTest()
{
}

public static void main(String args[])
{
try{
  Source sourcexsl  = new StreamSource(new
FileInputStream("D:\\Downloads\\InvoicePo.xsl"));

   Source sourceinst = new StreamSource(new
FileInputStream("D:\\Downloads\\InvoicePo.xml"));
   FileOutputStream fo = new
FileOutputStream("D:\\Downloads\\InvoicePoResult.xml");
   StreamResult result = new StreamResult(fo);

  try{
   Class factoryClass =
Class.forName("org.apache.xalan.processor.TransformerFactoryImpl");
   org.apache.xalan.processor.TransformerFactoryImpl
transformerFactoryImpl =
(org.apache.xalan.processor.TransformerFactoryImpl)factoryClass.newInstance();
   javax.xml.transform.Transformer transformer =
transformerFactoryImpl.newTransformer(sourcexsl);
   transformer.setOutputProperty(OutputKeys.INDENT, "yes");
     transformer.transform(sourceinst, result);
   }catch(javax.xml.transform.TransformerException tf)
   {
     System.out.println(tf.getMessageAndLocation());
     System.out.println(tf.getLocationAsString());
    }
} catch(Exception ex)
     {
       ex.printStackTrace();

     }
}

}


> 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