cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Painter-Wakefield <paint...@mc.duke.edu>
Subject Re: get-xml in ESQL problem
Date Mon, 08 Sep 2003 00:00:19 GMT
Nope, you can't do that.  XSP requires a single non-xsp-namespace element 
under xsp:page to be the root element for the output.  A simple workaround 
is to simply pass the output through an XSLT stylesheet (XSLT 
transformer).  You only need one very simple, fast template:

<xsl:template match="/text">
        <xsl:copy-of select="*"/>
</xsl:template>

but you probably already knew that, so perhaps you were looking for a way 
around it?  You could write your own generator, but of course you'd have 
to do your own JDBC calls.  The other way, I suppose, is to hack the XSP 
generation code (probably just the file 
org/apache/cocoon/components/language/markup/xsp/java/xsp.xsl) to allow a 
flag passed as an attribute to the xsp:page element, something like
<xsp:page ignore-root-element="true">
        <text>
                <esql:connection>
                        ...
 and so forth.  Then submit your change back to the project :)  Looking at 
the xsp.xsl should provide many insight into how the XSP generation works, 
so I recommend it anyway.

-Christopher





"g[R]eK" <gReK@warsztat.pac.pl>
09/06/2003 01:59 PM
Please respond to users

 
        To:     "users@cocoon.apache.org" <users@cocoon.apache.org>
        cc: 
        Subject:        get-xml in ESQL problem


<. Hi users! .>

  I have strange problem with ESQL. I want read xml from database as full 
xml
  document (not fragment). So I decided to use <esql:get-xml>, it works 
almost
  fine. 'Almost' because I must insert the xml from database in some tag, 
the
  root element of xml in database can't be root element in returned 
document.
  :-(

  My XSP and log are included below.

  This XSP works good:
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2">
        <text>
                <esql:connection>
                        <esql:pool>warsztat</esql:pool>
                        <esql:execute-query>
                                <esql:query>SELECT * FROM 
artykuly</esql:query>
                                <esql:results>
                                        <esql:row-results>
                                                <esql:get-xml 
column="text"/>
                                        </esql:row-results>
                                </esql:results>
                        </esql:execute-query>
                </esql:connection>
        </text>
</xsp:page>

  This XSP:
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2">
                <esql:connection>
                        <esql:pool>warsztat</esql:pool>
                        <esql:execute-query>
                                <esql:query>SELECT * FROM 
artykuly</esql:query>
                                <esql:results>
                                        <esql:row-results>
                                                <esql:get-xml 
column="text"/>
                                        </esql:row-results>
                                </esql:results>
                        </esql:execute-query>
                </esql:connection>
</xsp:page>

  raise exception:
 
DEBUG   (2003-09-06) 19:53.25:402   [core.program-generator] 
(/cocoon/cvs-local/warsztat/plain/artykuly/get-article.xml) 
Thread-11/ProgramGeneratorImpl: Got Language Exception
org.apache.cocoon.components.language.LanguageException: Error compiling 
get_article_template_xml:
ERROR 1 
(org\apache\cocoon\www\cvs_local\warsztat\artykuly\get_article_template_xml.java):
...
    if (_esql_query != null) {
      _esql_queries.push(_esql_query);
    }
// start error (lines 306-306) "Unhandled exception type SQLException"
    _esql_query = _esql_connection.createQuery(
// end error
             String.valueOf(""),
             String.valueOf(
      ""
 
...
ERROR 2 
(org\apache\cocoon\www\cvs_local\warsztat\artykuly\get_article_template_xml.java):
...
            if (!_esql_connection.getAutoCommit()) {
              _esql_connection.rollback();
            }
          } catch (Exception _esql_exception_N10012_2) {}
// start error (lines 408-408) "Unhandled exception type SQLException"
          throw new RuntimeException("Error executing statement: " + 
_esql_query.getQueryString() + ": "+_esql_exception_N10012);
// end error
 
    } finally {
        _esql_query.cleanUp();
    }
...
Line 306, column 0: Unhandled exception type SQLException
Line 408, column 0: Unhandled exception type SQLException
        at 
org.apache.cocoon.components.language.programming.java.JavaLanguage.compile(JavaLanguage.java:236)
        at 
org.apache.cocoon.components.language.programming.CompiledProgrammingLanguage.load(CompiledProgrammingLanguage.java:208)
        at 
org.apache.cocoon.components.language.generator.ProgramGeneratorImpl.loadProgram(ProgramGeneratorImpl.java:427)
        at 
org.apache.cocoon.components.language.generator.ProgramGeneratorImpl.load(ProgramGeneratorImpl.java:339)
        at 
org.apache.cocoon.generation.ServerPagesGenerator.setup(ServerPagesGenerator.java:202)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.setupPipeline(AbstractProcessingPipeline.java:381)
        at 
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.setupPipeline(AbstractCachingProcessingPipeline.java:652)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.preparePipeline(AbstractProcessingPipeline.java:508)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.prepareInternal(AbstractProcessingPipeline.java:520)
        at 
org.apache.cocoon.components.source.impl.SitemapSource.init(SitemapSource.java:387)
        at 
org.apache.cocoon.components.source.impl.SitemapSource.<init>(SitemapSource.java:248)
        at 
org.apache.cocoon.components.source.impl.SitemapSourceFactory.getSource(SitemapSourceFactory.java:99)
        at 
org.apache.excalibur.source.impl.SourceResolverImpl.resolveURI(SourceResolverImpl.java:247)
        at 
org.apache.cocoon.components.CocoonComponentManager.resolveURI(CocoonComponentManager.java:503)
        at 
org.apache.cocoon.components.CocoonComponentManager.resolveURI(CocoonComponentManager.java:503)
        at 
org.apache.cocoon.environment.AbstractEnvironment.resolveURI(AbstractEnvironment.java:513)
        at 
org.apache.cocoon.environment.AbstractEnvironment.resolveURI(AbstractEnvironment.java:500)
        at 
org.apache.cocoon.generation.FileGenerator.setup(FileGenerator.java:104)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.setupPipeline(AbstractProcessingPipeline.java:381)
        at 
org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.setupPipeline(AbstractCachingProcessingPipeline.java:652)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.preparePipeline(AbstractProcessingPipeline.java:508)
        at 
org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:470)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode.invoke(SerializeNode.java:147)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:84)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:164)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:108)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:164)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:108)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:161)
        at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:327)
        at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:309)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:133)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:84)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:164)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:108)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:164)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:108)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:161)
        at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:327)
        at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:309)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:133)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:84)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:164)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:108)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:164)
        at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:108)
        at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:161)
        at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:327)
        at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:309)
        at org.apache.cocoon.Cocoon.process(Cocoon.java:639)
        at 
org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1096)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
        at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
        at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at 
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
        at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at 
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
        at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
        at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
        at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at 
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at 
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
        at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
        at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
        at 
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
        at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
        at java.lang.Thread.run(Thread.java:536)


-- 
Best regards
<. g[R]eK mailto:gReK@warsztat.pac.pl                                    .>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org




Mime
View raw message