Thanks. Well, the variable definition clearly isn't circular, so we have to look for a deeper cause. I suspect some kind of multi-threading issue. Saxon holds a flag that indicates the variable is being evaluated, and the error means that an attempt is being made to evaluate the variable when this flag is already set. The flag is contained in the JAXP Transformer object, so a possible explanation is that the Transformer is being used in more than one thread (which isn't allowed). I notice that net.sf.saxon.Controller (which is Saxon's implementation of the JAXP Transformer) is mentioned in the ClassLoader message, so this might be a hint that things are amiss in this area.
 
Note that because the variable calls the doc() function to load and parse a source document, evaluation of the variable might take some time, so it's quite likely that if there is a threading conflict here, this is where it would be detected. 
 
Does this ring any bells?
 
Michael Kay
http://www.saxonica.com/