Closed Bug 306539 Opened 19 years ago Closed 18 years ago

Error during XSLT transformation: (null)

Categories

(Core :: XSLT, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: craigm, Assigned: peterv)

Details

Attachments

(3 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6

Problem was incountered using XML - XSL  "<xsl:variable > Xpath function" 
On further analysis the problem was not the physical variable declaration but
where the declaration Lay in relation to the rest of the Dcoument. 

The variable declaration was effected by <TD> tags ?? 

This problem is not reproduced in IE ... 



Reproducible: Always

Steps to Reproduce:
1.Create a for nested <xsl:for-each> loop (2 Nests is suffiecient)
2.declare a variable in the first loop - 
3.call variable in the secound loop ? - 


Eg : 
<TABLE>
<xsl:for-each select="//vw_get_PartnerDetails">
<!-- The DECLARATION MUST BE HERE FOR IT TO WORK 
<xsl:variable name="checkPartnerId" select="@partnerId"  />				-->			
<TR>
	<TD class="tableGradient">
		<xsl:value-of select="@companyName" /> <xsl:value-of select="@tradingStyle" />
	</TD>
	<TD class="tableGradient">	
	<!-- **** PROBLEM IS HERE This Declaration should B moved TO the 1st TR-->
				<xsl:variable name="checkPartnerId" select="@partnerId"  />								
				<xsl:value-of select="$checkPartnerId" />	
	</TD>
</TR>
<TR>
	<TD class="tableGradient" colspan="3">
		<div >
		<xsl:variable name="checkPartnerId" select="@partnerId"  />							
			<xsl:for-each select="//vw_get_All_PartnerContacts" >				
					
			<xsl:variable name="contactPartnerId" select="@PContactId" />
		<!-- **** PROBLEM 		
			<xsl:if test="$contactPartnerId =$checkPartnerId" >
				
							Name : <xsl:value-of select="@name" /> <xsl:value-of
select="@surname" />		<br/>		
							PartnerId : <xsl:value-of select="@partnerId" />		<br/>		
							ContactId : <xsl:value-of select="@contactId" />		<br/>										
								
				</xsl:if>									
			</xsl:for-each>
			
		</div>
	</TD>
</TR>	

</xsl:for-each>
</TABLE>


Actual Results:  
Error during XSLT transformation: (null)

Expected Results:  
The Page to work

The <xsl:variable> declaration should exist outside any tags that could effect
the XML parser / engine into thinking that the node / variable does not exists
in the current path ? not sure if this is the case though. 
It seems the variable is only pertenant to the TD element and Undeclared when
moving in / out of other tags.
Component: General → Build Config
Product: Firefox → Core
QA Contact: general → build-config
Version: unspecified → 1.7 Branch
Assignee: nobody → peterv
Component: Build Config → XSLT
QA Contact: build-config → keith
Please attach a *minimal* stylesheet that does not behave as you think it should and attach an xml file exposing the bug.
I think I was able to reproduce the error message with the lines below. The problem showed up in a nested loop (as Craig reported) but finally it boiled down to the double assignments - the <mybook.../> is not need either. Removing either one of the assignments makes it work.
BTW, I used FF 2.0.


stylesheet.xsl
--------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes"/>
<xsl:template match="/data">

<books>
  <xsl:variable name="found" select="false()"/>
  <mybook ref="abc"/>
  <xsl:variable name="found" select="true()"/>
</books>

</xsl:template>
</xsl:stylesheet>


data.xml
--------
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
<data>
  <entry name="ABC"/>
  <entry name="DEF"/>
</data>


Regards,
-Thomas
Ok, just outed myself as a XSLT beginner stumbling over the "variables are not reassignable" gotcha. So the example I posted before is nonsense of course, but I believe

1. Craig's code shows the same problem reassigning the variable checkPartnerId

2. The reported cause of the error "(null)" is not really descriptive, something like "illegal reassignment to variable" would be helpful.

-Thomas
Attached patch v1Splinter Review
Error reporting seems to have been broken for a while :-/.
Attachment #247661 - Flags: superreview?(bugmail)
Attachment #247661 - Flags: review?(bugmail)
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #247661 - Flags: superreview?(bugmail)
Attachment #247661 - Flags: superreview+
Attachment #247661 - Flags: review?(bugmail)
Attachment #247661 - Flags: review+
Attached patch TestcaseSplinter Review
Even with attachment 247661 [details] [diff] [review] we still show (null) as the error message on this testcase. Patch coming up for that.
Attachment #247979 - Flags: superreview?(bugmail)
Attachment #247979 - Flags: review?(bugmail)
Attachment #247979 - Flags: superreview?(bugmail)
Attachment #247979 - Flags: superreview+
Attachment #247979 - Flags: review?(bugmail)
Attachment #247979 - Flags: review+
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
OS: Windows 2000 → All
Priority: -- → P3
Hardware: PC → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9alpha
Version: 1.7 Branch → Trunk
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: