Project

Profile

Help

attribute in attribute, variable not declared

Added by Anonymous about 20 years ago

Legacy ID: #2826186 Legacy Poster: marcvc (marcvc)

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


Replies (3)

Please register to reply

RE: attribute in attribute, variable not decl - Added by Anonymous about 20 years ago

Legacy ID: #2826229 Legacy Poster: Michael Kay (mhkay)

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

RE: attribute in attribute, variable not declared - Added by Anonymous about 20 years ago

Legacy ID: #2826252 Legacy Poster: marcvc (marcvc)

I fully understand... Actually it was rather by accident I ran into it. Nothing urgent, nothing blocking, such restrictions seem reasonable. Marc

RE: attribute in attribute, variable not decl - Added by Anonymous about 20 years ago

Legacy ID: #2826287 Legacy Poster: Michael Kay (mhkay)

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

    (1-3/3)

    Please register to reply