attribute in attribute, variable not declared

Help
marcvc
2004-10-28
2012-10-08
  • marcvc

    marcvc - 2004-10-28

    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

     
    • Michael Kay

      Michael Kay - 2004-10-28

      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

       
    • marcvc

      marcvc - 2004-10-28

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

      Marc

       
    • Michael Kay

      Michael Kay - 2004-10-28

      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

       

Log in to post a comment.