cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fo...@neonics.com
Subject Re: how can I do this ? (in C2???)
Date Thu, 11 Jan 2001 15:17:55 GMT


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
> 


Mime
View raw message