Maybe - if someone could suggest a better way to do this I'd really
appreciate it.

I've created a logicsheet - inside the "xsp:page" template match, I've
created some String variables which represent the different string columns
in the database table (for a particular row).  When the XML page is called,
I use esql to select the values out of the database (returns one row based
on an ID passed in).  I then set these variables to their respective values
from the table.  Here is an example from the logicsheet:

  <xsl:template match="xsp:page">
    <xsp:page>
      <xsl:copy>
        <xsl:apply-templates select="@*"/>
      </xsl:copy>

      <xsp:structure>
        <xsp:include>java.sql.*</xsp:include>
        <xsp:include>com.rrp.globals.*</xsp:include>
      </xsp:structure>

      <xsp:logic>
        private static String projID = "0";
        private static String projTitle = "Project Title";
     </xsp:logic>

      <xsl:apply-templates/>

    </xsp:page>
  </xsl:template>

  <xsl:template match="projects:loadDetails">
    ....
    <esql:connection>
    <esql:driver>org.gjt.mm.mysql.Driver</esql:driver>
    ....
       <esql:row-results>
          <xsp:logic>
            projTitle = <esql:get-string column="Title"/>;
          </xsp:logic>
        </esql:row-results>
    ....
  </xsl:template>

I then created different templates which returned the values so I could
basically create a "detail" level XML file which showed info for that row in
the database.

E.g.


  <xsl:template match="projects:Title">
    <b><xsp:expr>projTitle</xsp:expr></b>
  </xsl:template>

I could always just put all the HTML/XML that I want to use to print out the
details inside the <esql:row-results> and have all the formatting for the
details page in the logicsheet - but I would rather keep the content (info
other than DB data) inside the XML file and use tags that return the data.

Any other ways of accomplishing this?

Thanks,

- Brent

> -----Original Message-----
> From: Stefan Seifert [mailto:[EMAIL PROTECTED]]
> Sent: Monday, August 20, 2001 5:05 PM
> To: [EMAIL PROTECTED]
> Subject: AW: esql, get-xml and xsp:logic
>
>
> Take a look at the generate Java class behind the XSP page - and you
> will see the problem. get-xml does not an xml string, but a xml dom
> element object (or sax events in cocoon 2). In your second case there
> was just the .toString()-Method of org.w3c.dom.Element called.
>
> I can see not much sense in putting the xml fragment in a string (i
> think you had some misleading thinking here), but if you really need it,
> just use get-string instead of get-xml, this returns the plain text of
> the column.
>
> Stefan
>
> > -----Ursprüngliche Nachricht-----
> > Von: Brent L Johnson [mailto:[EMAIL PROTECTED]]
> > Gesendet: Dienstag, 21. August 2001 01:16
> > An: Cocoon-Users
> > Betreff: esql, get-xml and xsp:logic
> >
> >
> > I've been using <esql:get-xml column="COLNAME"
> > root="fragment"/> and it's
> > been working perfectly.  But, I've found a problem when
> > trying to set a
> > String inside an <xsp:logic> tag to that.  Make any sense?
> > Here's the code
> > that works...
> >
> > <esql:row-results>
> > TEST: <esql:get-xml column="mycol" root="fragment"/>
> > </esql:row-results>
> >
> > But, I want to set a string to that value.. e.g.
> > <xsp:logic>
> > String myval = <esql:get-xml column="mycol" root="fragment"/>;
> > </xsp:logic>
> >
> > Doing this I get the following error:
> > Incompatible type for =. Can't convert org.w3c.dom.Element to
> > java.lang.String.
> >
> > Then I tried this (which ALMOST works):
> > <xsp:logic>
> > String myval = "" + <esql:get-xml column="mycol" root="fragment"/>;
> > </xsp:logic>
> >
> > Unfortunately - this only gives me the string "[fragment:
> > null]".  Does this
> > have something to do with the order that the XSP and XSL is
> > processed???
> >
> > Thanks,
> >
> > - Brent
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
>
>
>
>


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

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

Reply via email to