[ http://nagoya.apache.org/jira/browse/XALANJ-2010?page=comments#action_56650 ] Henry Zongaro commented on XALANJ-2010: ---------------------------------------
The root cause of this problem is that Xalan-J crosses the boundaries of different APIs that throw different kinds of exceptions in building its internal representation of a stylesheet. Xalan-J uses a SAX parser to drive construction of its internal representation of a stylesheet. It finds an error in the stylesheet -- in this case, an empty attribute where an XPath expression was expected -- and throws a TransformerException. That exception reaches the ContentHandler that is receiving the SAX events. The ContentHandler.startElement interface is only able to throw SAXExceptions, so the implementation wraps the TransformerException in a SAXException and throws that. The SAXException is eventually caught by TransformerFactory.newTemplates, which wraps that in another TransformerException. The location information is available in the innermost TransformerException, but that's unknown to the outer TransformerException. That's all just background information for anybody investigating the problem. A work-around for this problem is to specify an implementation of the ErrorHandler interface using TransformerFactory.setErrorHandler. That will give you access to the inner TransformerException, and its location information, when it's created. > 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]
