Variable not defined sometimes?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Variable not defined sometimes?

Post by sderrick »

This is an odd problem and to make matters worse its inconsistent.

When stepping into a template and then stepping through the variable instantiation code the variables and params are not available for inspection?

If I inspect the value the variables are being set to I can access that info?

An example
<xsl:param name="ref"/>

<xsl:variable name="textNode" select="if($ref/@xml:lang and $ref/@xml:lang='german') then //tei:text[not(@xml:lang)] else //tei:text[@xml:lang='german']"/>

the param ref is available immediately after stepping over it.

But as soon as I step into the variable textNode code the param ref is not availble and watching it I get an error that it is not declared. After stepping out of the textNode code both the param and variable textNode are still not available?

Is this normal?
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Variable not defined sometimes?

Post by adrian »

Hello,

What version and build number of Oxygen are you using(Help -> About)?

This is usually determined by the way the debugging engine provides the current context. For Saxon-HE/PE/EE this behavior can be usually be changed from the Optimization level found under Advanced options(the toolbar button at the right of the engine combo box, with a small cog icon). Reduce the optimization level and see if that makes any difference.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Variable not defined sometimes?

Post by sderrick »

adrian wrote:Hello,
What version and build number of Oxygen are you using(Help -> About)?
Regards,
Adrian
<oXygen/> XML Editor 13.2, build 2012011017

I will lower the optimization level. it was set at 10 which I assume is the highest.

This effects only debugging and not when applying a transformation is that correct?

thanks

Scott
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Variable not defined sometimes?

Post by sderrick »

I lowered the opt level down to 0.

didn't fix anything.

Scott
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Variable not defined sometimes?

Post by adrian »

If that didn't change anything then I'm afraid this is just how Saxon provides the variables in context.

I'll log this to our issue tracking tool to investigate. If the problem is indeed from Saxon we will forward it to Saxonica.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Variable not defined sometimes?

Post by sderrick »

I think I figured out when it happens, an example

Code: Select all


    <xsl:template name="paragraphLangLink">
<xsl:param name="ref"/>
<xsl:param name="content"/>
<xsl:param name="modifyFontStyle"/>

<xsl:variable name="textNode" select="if($ref/@xml:lang and $ref/@xml:lang='german') then //tei:text[not(@xml:lang)] else //tei:text[@xml:lang='german']"/>
When I step into the template above as I step over(instantiate) each param it becomes available as you would expect.
When i hit the variable declaration that uses an if() statement the params or any preceding variables are no longer available(you get an error if you try to watch them) and they don't come back after you come back out of the if() statement.
Its like the context changes and never returns correctly for the debugger. The params are there because the code executes correctly that is using them, but you don't have access to them in the debugger.
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Variable not defined sometimes?

Post by adrian »

Hi,

So, to avoid any confusion, you're using Saxon-PE 9.3.0.5, right?

I can confirm the first part:
When i hit the variable declaration that uses an if() statement the params or any preceding variables are no longer available(you get an error if you try to watch them)
but not the second:
and they don't come back after you come back out of the if() statement.
I can't reproduce this, this may depend on the code that follows the variable declaration.

After the variable declaration I've added a value-of:

Code: Select all

<xsl:value-of select="$textNode"/>
and when entering this, the context is again available.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Variable not defined sometimes?

Post by sderrick »

Yes I agree, the variables in the current context always disappear if an if() statement is reached.

The restoration of the context is problematic.

I still think this is a "MAJOR" bug. There is no way to debug variable construction if the declaration(s) are more complex than a simple assignment. How useless is that!

It makes no difference to me whether the root of the bug is in Oxygen or Saxon. It makes Oxygen's built in debugger useless at times.

If Saxon is unwilling to look at or fix the problem I think you guys need to work around it and supply us with a debugger that allows me to see the current context.

In my opinion you guys make a world class product, and you should not let Saxon bring it down.

Scott
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Variable not defined sometimes?

Post by adrian »

Like I said, this has been logged to our issue tracking tool and it will be investigated. If the problem is indeed from Saxon we will forward it to Saxonica.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Variable not defined sometimes?

Post by adrian »

Hi,

This bug has reached the analysis stage and we're trying to determine what's causing the restoration of the context problem that you're describing. As I've mentioned in one of my previous comments I could not reproduce this particular problem with the code you provided. After your sample code I've added a simple xsl:copy-of that uses that variable:

Code: Select all

<xsl:copy-of select="$textNode"/>
But this code does not seem to trigger the restoration of the context problem you're describing. After reaching the if (where the entire context is invalidated) and pressing Step In, the debugger stops on the xsl:copy-of that I've added and I get the correct variables in context: textNode (evaluated only if the optimization level was set to 0), ref, modifyFontStyle and content.
After another Step In the debugger finishes execution because of the limited sample.

Could you please tell me what follows in your code after the textNode variable definition?
A full stylesheet would be very useful for analyzing this, or at least the complete xsl:template.
If you want to keep it off the forum, you can send it to our support email address: support AT oxygenxml DOT com


For the other problem "the variables in the current context always disappear if an if() statement is reached" we already have a sample that reproduces the issue and we are currently looking into a solution.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: Variable not defined sometimes?

Post by adrian »

Hi,

We've isolated and resolved the problem ("the variables in the current context always disappear if an if() statement is reached") in the current development stream and the bugfix will be available in v14.1.
The context was lost (variables being undefined) when the debugger was tracing into XPath expressions. This feature is controlled by an option: Options > Preferecnes > XML > XSLT-FO-XQuery > XSLT > Saxon > Saxon-HE/PE/EE, Debugger trace into XPath expressions.
For older versions of Oxygen (v14.0 and earlier) you can disable this option to avoid the issue, if you find it troublesome.

If you're interested in a beta of v14.1 to test this bugfix, please write to our support email address: support AT oxygenxml DOT com

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Variable not defined sometimes?

Post by sderrick »

Fantastic news!!! :D

I'll wait for the official release of 14.1 as I'm up to my elbows in a xml transformation project and don't have time righ tnow to play beta tester.

thanks for pursuing this.

Scott
Post Reply