Don't ask me how I've run into this, it would bring us too far ;-)
Consider the following query:
<e a = "{for $v in 10 return <e a="{$v}">{$v}</e>}"/>
Saxon 8.x reports:
Variable $v has not been declared
I've the impression that this only happens when a direct attribute constructor is used inside another one.
I know, the attribute constructor inside the other one is not relevant (atomization, etc), but nevertheless it should work?
Thanks,
Marc
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Parsing of expressions within attribute constructors is pretty tortuous because its the only place where you can use a namespace prefix before declaring it. So Saxon handles the static context differently in this situation, which is probably what's causing the trouble. I must admit I've never tested an attribute constructor inside another attribute constructor, and the opportunities for nested namespace declarations are frankly pretty horrifying. In the short term, I think I'm going to have to document some restrictions here - like no namespace declarations allowed in an element constructor that's nested within an attribute constructor.
Michael Kay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Michael,
Don't ask me how I've run into this, it would bring us too far ;-)
Consider the following query:
<e a = "{for $v in 10 return <e a="{$v}">{$v}</e>}"/>
Saxon 8.x reports:
Variable $v has not been declared
I've the impression that this only happens when a direct attribute constructor is used inside another one.
I know, the attribute constructor inside the other one is not relevant (atomization, etc), but nevertheless it should work?
Thanks,
Marc
Yes, it should work.
Parsing of expressions within attribute constructors is pretty tortuous because its the only place where you can use a namespace prefix before declaring it. So Saxon handles the static context differently in this situation, which is probably what's causing the trouble. I must admit I've never tested an attribute constructor inside another attribute constructor, and the opportunities for nested namespace declarations are frankly pretty horrifying. In the short term, I think I'm going to have to document some restrictions here - like no namespace declarations allowed in an element constructor that's nested within an attribute constructor.
Michael Kay
I fully understand... Actually it was rather by accident I ran into it.
Nothing urgent, nothing blocking, such restrictions seem reasonable.
Marc
For the moment I've fixed it by changing line 2010 in QueryParser.java from
if ("xmlns".equals(attName) || attName.startsWith("xmlns:")) {
to
if ("xmlns".equals(attName) || attName.startsWith("xmlns:") || scanOnly) {
But somehow I suspect there are deeper problems lurking.
Michael Kay