You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Piyush Sheth <pi...@imagine-sw.com> on 2001/01/10 19:09:04 UTC

how can I do this ?

 my logicsheet looks like this
-----
------
----
<xsp:structure>mylib.*</xsp:structure>
<xsp:logic>
     private String get( String param )
     {
           new mylib.foo( param ).toString();
     }
</xsp:logic>

<xsl:template match="mns:substitute"/>
<!-- here I want call get("somethin") defined above
and use its returned value in xsl:if.

<xsl:if test=get("somethin")   .....



-->
</xsl:template>
-------
--------
-------
------

How do I do that ?



Piyush.



Re: how can I do this ?

Posted by Michael Zach <mi...@gmx.at>.
Hi,

maybe have a look at http://www.suranyami.com/XSPtutorial/ too, it gives
some easy showing of XSP logicsheets ...

Michael
----- Original Message -----
From: "Piyush Sheth" <pi...@imagine-sw.com>
To: <co...@xml.apache.org>
Sent: Wednesday, January 10, 2001 7:09 PM
Subject: how can I do this ?


> my logicsheet looks like this
> -----
> ------
> ----
> <xsp:structure>mylib.*</xsp:structure>
> <xsp:logic>
>      private String get( String param )
>      {
>            new mylib.foo( param ).toString();
>      }
> </xsp:logic>
>
> <xsl:template match="mns:substitute"/>
> <!-- here I want call get("somethin") defined above
> and use its returned value in xsl:if.
>
> <xsl:if test=get("somethin")   .....
>
>
>
> -->
> </xsl:template>
> -------
> --------
> -------
> ------
>
> How do I do that ?
>
>
>
> Piyush.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>


Re: how can I do this ? (in C2???)

Posted by fo...@neonics.com.

Hello there,

this example should work fine in C1 but I'm trying to get something
like this working in C2..

Since you sound like an expert (not that I didn't already know what
you explained ;)) could you deliver this stylesheet to me working
under C2? The only difference in your stylesheet compared to mine was the
inclusion of the <xsl:copy/> tag. 





On Wed, 10 Jan 2001, Donald Ball wrote:

> On Wed, 10 Jan 2001, Piyush Sheth wrote:
> 
> >  my logicsheet looks like this
> > -----
> > ------
> > ----
> > <xsp:structure>mylib.*</xsp:structure>
> > <xsp:logic>
> >      private String get( String param )
> >      {
> >            new mylib.foo( param ).toString();
> >      }
> > </xsp:logic>
> >
> > <xsl:template match="mns:substitute"/>
> > <!-- here I want call get("somethin") defined above
> > and use its returned value in xsl:if.
> >
> > <xsl:if test=get("somethin")   .....
> >
> >
> >
> > -->
> > </xsl:template>
> > -------
> > --------
> > -------
> > ------
> >
> > How do I do that ?
> 
> you're really mangling the logicsheet concept here. logicsheets are xslt
> stylesheets which are applied to xsp pages to transform tags in special
> namespaces into tags (and content) in the xsp namespace. e.g. this page
> 
> <esql:connection>
>   <esql:driver>org.postgresql.Driver</esql:driver>
>   ...
> </esql:connection>
> 
> is transformed into (something like) this:
> 
> <xsp:logic>
>   Class.forName("org.postgresql.Driver").newInstance();
>   ...
> </xsp:logic>
> 
> and then finally transformed into a java class.
> 
> okay so far? good. now, you're trying to evalute a java method inside an
> xpath expression:
> 
> > <xsl:if test=get("somethin")   .....
> 
> you can't _do_ that. when your logicsheet is being applied, the java class
> doesn't even _exist_ yet, you can't call one of its methods. you're in the
> process of _creating_ the java class at logicsheet application time.
> 
> for the record, your logicsheet should look something more like this:
> 
> <xsl:template match="xsp:page">
>   <xsl:copy>
>     <xsl:apply-templates select="@*"/>
>     <xsp:structure>
>       <xsp:include>mylib.*</xsp:include>
>     </xsp:structure>
>     <xsp:logic>
>       private String get(String param) {
>         new mylib.foo( param ).toString();
>       }
>     </xsp:logic>
>     <xsl:apply-templates/>
>   </xsl:copy>
> </xsl:template>
> 
> <xsl:template match="mns:substitute">
>   <xsp:logic>
>     if ("bar".equals(get("foo"))) {
>       ...
>     }
>   </xsp:logic>
> </xsl:template>
> 
> <xsl:template match="@*|node()" priority="-1">
>   <xsl:copy>
>     <xsl:apply-templates select="@*|node()"/>
>   </xsl:copy>
> </xsl:template>
> 
> - donald
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 


Re: how can I do this ?

Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 10 Jan 2001, Piyush Sheth wrote:

>  my logicsheet looks like this
> -----
> ------
> ----
> <xsp:structure>mylib.*</xsp:structure>
> <xsp:logic>
>      private String get( String param )
>      {
>            new mylib.foo( param ).toString();
>      }
> </xsp:logic>
>
> <xsl:template match="mns:substitute"/>
> <!-- here I want call get("somethin") defined above
> and use its returned value in xsl:if.
>
> <xsl:if test=get("somethin")   .....
>
>
>
> -->
> </xsl:template>
> -------
> --------
> -------
> ------
>
> How do I do that ?

you're really mangling the logicsheet concept here. logicsheets are xslt
stylesheets which are applied to xsp pages to transform tags in special
namespaces into tags (and content) in the xsp namespace. e.g. this page

<esql:connection>
  <esql:driver>org.postgresql.Driver</esql:driver>
  ...
</esql:connection>

is transformed into (something like) this:

<xsp:logic>
  Class.forName("org.postgresql.Driver").newInstance();
  ...
</xsp:logic>

and then finally transformed into a java class.

okay so far? good. now, you're trying to evalute a java method inside an
xpath expression:

> <xsl:if test=get("somethin")   .....

you can't _do_ that. when your logicsheet is being applied, the java class
doesn't even _exist_ yet, you can't call one of its methods. you're in the
process of _creating_ the java class at logicsheet application time.

for the record, your logicsheet should look something more like this:

<xsl:template match="xsp:page">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <xsp:structure>
      <xsp:include>mylib.*</xsp:include>
    </xsp:structure>
    <xsp:logic>
      private String get(String param) {
        new mylib.foo( param ).toString();
      }
    </xsp:logic>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

<xsl:template match="mns:substitute">
  <xsp:logic>
    if ("bar".equals(get("foo"))) {
      ...
    }
  </xsp:logic>
</xsl:template>

<xsl:template match="@*|node()" priority="-1">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

- donald