I'll take a stab at it...

You don't need java for looping over the rows, that is already done by the
esql logicsheet when you use <esql:row-results>.  You can mix <xsp:logic>
and ESQL tags as needed however.  Here's some code (below) that might be
close to what you want to do.  Note I wasn't sure everywhere what you were
trying to do with your queries, and some of them didn't make sense to me,
so I made guesses as to what your database schema looks like and rewrote
the queries accordingly.  Hopefully it will help make some sense of this
for you.  Also note I've used java to get a foreign key (I made up the
column name, but I assume it must exist) from the section table for use in
the chapter table, but ESQL also provides some features that would allow
you to avoid even this little bit of java.  I'm not real familiar with it,
but presumably it is documented in the ESQL documentation.  Anyway, this
shows you that you can easily mix <xsp:logic> and ESQL tags.

<?xml version="1.0" encoding="UTF-8"?>
<xsp:page
  xmlns:xsp="http://apache.org/xsp";
  xmlns:esql="http://apache.org/cocoon/SQL/v2";
>
  <Document
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:noNamespaceSchemaLocation="schema.xsd"
  >
    <!-- Get Document -->
    <esql:connection>
      <esql:pool>xmldb</esql:pool>
      <esql:execute-query>
        <esql:query>select * from document where DocID = 1</esql:query>
        <esql:results>
          <esql:row-results>
            <DocObj><esql:get-string column="DocObject"/></DocObj>
            <DocTitle><esql:get-string column="DocTitle"/></DocTitle>
            <DocVer><esql:get-string column="DocVersion"/></DocVer>
            <DocAuth><esql:get-string column="DocAuthor"/></DocAuth>
            <DocDate><esql:get-date column="DocData"/></DocDate>
          </esql:row-results>
        </esql:results>
      </esql:execute-query>

      <!-- Get Sections -->
      <esql:execute-query>
        <esql:query>select * from section where DocID = 1</esql:query>
        <esql:results>
          <!-- Loop over sections - no xsp:logic needed, this is already a
java loop -->
          <esql:row-results>
            <Section>
              <SecTitle><esql:get-string column="SecTitle"/></SecTitle>
              <SecContent><esql:get-string column
="SecContent"/></SecContent>
              <xsp:logic>
                <!-- Save your foreign key for the chapter table -->
                String section = <esql:get-string column="SecID"/>;
              </xsp:logic>

              <!-- Get Chapters for this Section -->
              <esql:execute-query>
                <esql:query>
                  select * from chapter
                  where DocID = 1 AND Section=
                    <esql:parameter type="string">
                      <xsp:expr>section</xsp:expr>
                    </esql:parameter>
                </esql:query>
                <esql:results>
                  <!-- Loop over Chapters -->
                  <esql:row-results>
                    <Chapter>
                      <ChapTitle><esql:get-string column
="ChapTitle"/></ChapTitle>
                      <ChapContent><esql:get-string column
="ChapContent"/></ChapContent>
                    </Chapter>
                  </esql:row-results>
                </esql:results>
              </esql:execute-query>

            </Section>
          </esql:row-results>
        </esql:results>
      </esql:execute-query>
    </esql:connection>
  </Document>
</xsp:page>




Hi, it's me again ... could some one give me a hint how to use <xsp:logic>
in the right way ?

I have to generate a document structure like this:
document
      section A
         chapter 1
         chapter 2
      section B
         chapter 3

  My problem is to combine the logic with my esql tags.

<xsp:page laguage="java" xmlns:xsp="http://apache.org/xsp";
xmlns:esql="http://apache.org/cocoon/SQL/v2";>
 <Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="schema.xsd"
xmlns:esql="http://apache.org/cocoon/SQL/v2"; xmlns:xsp="
http://apache.org/xsp";>
  <esql:connection>
   <esql:pool>xmldb</esql:pool>
         <Document>
 <esql:execute-query>
    <esql:query>select * from document</esql:query>
    <esql:results>
     <esql:row-results>
      <DocObj><esql:get-string column="DocObject"/></DocObj>
      <DocTitle><esql:get-string column="DocTitle"/></DocTitle>
      <DocVer><esql:get-string column="DocVersion"/></DocVer>
      <DocAuth><esql:get-string column="DocAuthor"/></DocAuth>
      <DocDate><esql:get-date column="DocData"/></DocDate>
     </esql:row-results>
    </esql:results>
   </esql:execute-query>
  <Section>
    <esql:execute-query>
     <esql:query>select * from section where DocID 1</esql:query>
      // Here I have to make an output first for the section A and all its
chapters and after that I have to realize an output of the section B and
all its chapters ...
       how can I realize it ?
                        <xsp:logic>
                          for (int x=0; x< =<esql:row-results>; x++){
     <esql:results>
      <esql:row-results>
       <SecTitle><esql:get-string column="SecTitle"/></SecTitle>
       <SecContent><esql:get-string column="SecContent"/></SecContent>
      </esql:row-results>
     </esql:results>
    </esql:execute-query>

    <Chapter>
     <esql:execute-query>
      <esql:query>select * from chapter where Chapter= nr  AND
Section=A</esql:query>

                                               <xsp:logic>
                                                          for (int y=0;
y<=<esql:row-results>; y++){
                                            <esql:results>
       <esql:row-results>
        <ChapTitle><esql:get-string column="ChapTitle"/></ChapTitle>
        <ChapContent><esql:get-string column="ChapContent"/></ChapContent>
       </esql:row-results>
      </esql:results>
                                                          }
      </xsp:logic>
       </esql:execute-query>
                                }
                               </xsp:logic>
              </Chatpter>
  </Section>
           </sql:connection>
   </Document>

Is it possible to use esql or better to write everything in Java? I am
really new to all this stuff ... sorry if I mix up everything ...
J.





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to