cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergio Carvalho <scarva...@criticalsoftware.com>
Subject Re: [C1][Bug] esql taglib bug in get-xml tag
Date Mon, 29 Jan 2001 12:37:38 GMT

Sorry Donald, you misread my e-mail; I apologize if I mangled my explaining a bit. I still
believe I bumped into an esql taglib bug, which I describe pretty well, but I was unable to
fix it, and now I need your help.

Rephrasing my problem. This Java code snippet, generated by the corresponding XML snippet:
-- (Source XML snippet)
(...)
     <esql:row-results>
       <esql:get-xml column="nitf"/>
     </esql:row-results>
(...)
-- (Generated Java snippet)
   while (_esql_query.resultset.next()) {
// ********** Error in the line below
      this.xspParser.parse(new InputSource(new StringReader(_esql_query.resultse    ))).getDocumentElement()
      if (_esql_query.max_rows != -1 && _esql_query.position - _esql_query.skip_ 
      break;
      }
      _esql_query.position++;
    }
--
is syntactically incorrect. It lacks the terminating semicolon, and doesn't even compile.
Even if I'd put the semicolon, it would compile, but it would do nothing. The faulty line
is expected to insert the query results as an XML fragment in the current node, and there's
no insertion function call in there, just the parsing call.

Now -- and here I wasn't very clear -- if I use the get-xml tag below a parent node, the XML
source and resulting Java code are:
-- (XML source snippet)
(...)
     <esql:row-results>
      <nitf:nitf>
       <esql:get-xml column="nitf"/>
      </nitf:nitf>
     </esql:row-results>
(...)
-- (resulting Java snippet)
   while (_esql_query.resultset.next()) {
// Removed nitf:nitf insertion code
      xspCurrentNode.appendChild(
          xspExpr(this.xspParser.parse(new InputSource(new StringReader(_esql_qu    ))).getDocumentElement(),
document)
        );
      if (_esql_query.max_rows != -1 && _esql_query.position - _esql_query.skip_ 
      break;
      }
      _esql_query.position++;
    }
--
See? Now the code is correct (both syntactically and functionally). The previously present
parser call gets called as part of an appendChild call.

Now, my problem is that I can't use the second version, because I need the nitf column in
the DB to contain a valid XML document -- and that means I can have only one root element.
NITF (News Industry Text Format) contains several elements below nitf:nitf (nitf:head and
nitf:body most of the times). Even get-xml will refuse to insert an invalid document.

I believe my first use of get-xml is a valid one, and it should work. I didn't fix it because
I couldn't find out where is the xspCurrentNode.appendChild call generated, or why it doesn't
happen when I use get-xml in the first situation. I did manage to use get-xml the way I wanted
using xsp:logic tags to add the missing code, but it isn't a pretty sight :-(



On Mon, 29 Jan 2001 00:14:40 -0500 (EST)
Donald Ball <balld@webslingerZ.com> wrote:

> On Sun, 28 Jan 2001, Sérgio Carvalho wrote:
> 
> >
> > The esql taglib generates invalid Java source code when using the
> > get-xml tag with no parent XML element: (...)
> >      <esql:row-results>
> >        <esql:get-xml column="nitf"/>
> >      </esql:row-results>
> > (...)
> > The generated code is:
> >    while (_esql_query.resultset.next()) {
> > // ********** Error in the line below
> >       this.xspParser.parse(new InputSource(new StringReader(_esql_query.resultse
   ))).getDocumentElement()
> >       if (_esql_query.max_rows != -1 && _esql_query.position - _esql_query.skip_
       break;
> >       }
> >       _esql_query.position++;
> >     }
> 
> looks like valid java source code to me. it might throw some sort of
> exception when executed, but it should certainly compile. what exception
> do you get?

No, it definitely can't compile. The error line is an expression

> 
> > It works correctly if the get-xml tag is used like this:
> > (...)
> >      <esql:row-results>
> >       <nitf:nitf>
> >        <esql:get-xml column="nitf"/>
> >       </nitf:nitf>
> >      </esql:row-results>
> > (...)
> 
> > But I can't use it like this, as the <nitf:nitf> is the root element
> > of the document and then the nitf column would have several root
> > elements (not allowed).
> 
> so do it like this:
> 
> <esql:results>
>   <nitf:nitf>
>     <esql:row-results>
>       <esql:get-xml column="nitf"/>
>     </esql:row-results>
>   </nitf:nitf>
> </esql:results>
> 
> that's one variation. i think think of several others you might try as
> well.
> 
> - donald
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org
> 


-- 
Sergio Carvalho
---------------
scarvalho@criticalsoftware.com

If at first you don't succeed, skydiving is not for you

Mime
View raw message