On Jun 26, 2012, at 7:38 PM, C. M. Sperberg-McQueen wrote:

> I've encountered an unexpected behavior in 1.0RC.  I first encountered
> it in one of my own forms, but the simplest way to recreate it may be:
> 
> (1) Load the writers.xml example from the 1.0RC distribution, or from
> 
>    http://www.agencexml.com/xsltforms/writers.xml
> 
> (2) Click Show Books and Hide Books a few times.
> 
> (3) Click Profiler.
> 
> This ought in normal operation to produce a profile showing the profiler
> information we have all come to love.  What it produces instead, at the 
> moment, is a Javascript error message saying 
> 
>  XSLTForms Exception
>  --------------------------
> 
>  Error dispatching event 'xforms-model-construct' :
> 
>  xforms-link-exception


I think I have now identified the source of this error.

Adding calls to Xsltforms_browser.debugConsole.write
at various locations makes clear that the error is arising in the
Xsltforms_globals.profiling_data() function, specifically in the loop

        for (var expr in XsltForms_xpath.expressions) {
                        if (XsltForms_xpath.expressions.hasOwnProperty(expr)) {
                                exprtab[exprtab.length] = {expr: expr, 
evaltime: XsltForms_xpath.expressions[expr].evaltime};
                        }
        }

When I load writers.xml and click the Profiler button before having 
unloaded any author's booklist, then this loop executes eight times,
for the expressions 

  . != 'true'
  @firstname
  @lastname
  @selected
  @selected != 'true'
  @selected = 'true'
  choose(@selected != 'true', 'Show', 'Hide')
  writer

These are the XPath expressions occurring in writers.xml.

When I load the subform, by clicking Show Books, and then click Profiler, 
the loop executes eleven times:  eight times for the XPath expressions shown
above, and three more times for

  @title
  @year
  book

These are the XPath expressions in books.xml, the subform.

When I then unload the subform by clicking Hide Books, and click Profiler
a third time, I get an error message in the Profiler window, and the debugging
trace in the main-form window shows the loop being entered nine times; it
looks a lot as if the error were being raised when the loop tries to evaluate
XsltForms_xpath.expressions['@title'].evaltime.  

A little further examination suggests that after the subform is
unloaded, XsltForms_xpath.expressions['@title'] is null, so 
the attempt to get its 'evaltime' property produces an error, 
which causes the load of the profiler to fail.  

Changing the conditional in lines 302-304 of xsltforms.js (in 1.0RC) to

  if (XsltForms_xpath.expressions.hasOwnProperty(expr) && 
XsltForms_xpath.expressions[expr]) {
     exprtab[exprtab.length] = {expr: expr, evaltime: 
XsltForms_xpath.expressions[expr].evaltime};
  }

seems to allow the Profiler to launch normally even after the subform is
unloaded.  

Michael

-- 
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
****************************************************************





------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support

Reply via email to