You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Klaus Drechsler <dr...@gmx.net> on 2001/02/25 23:36:33 UTC

xsl question

Hi,

I have an xsp page looking something like that:

<mytag:content>
	<mytag:bool>myObject.isTrue()</mytag:bool>
	<mytag:bool>yourObject.isTrue()</mytag:bool>
	...
	<mytag:ok>myObject.someMethod()</mytag:ok>
	<mytag:error>yourObject.someMethod()</mytag:error>
</mytag:content>

Now I want a Logicsheet, that takes all <bool>´s and checks if they are all 
"true", eg:

if(myObject.isTrue()&yourObject.isTrue() ... ){
	myObject.someMethod();
}else{
	yourObject.someMethod();
}

I did not figure out, how to do this in an xsl taglib. I tried the following:

<xsl:template match="content">
	<xsp:logic>
	if(
	<xsl:for-each select="bool">
		<xsl:copy-of select="."/>
		<xsl:if test="not(Position()=last())">
			<xsl:text>&</xsl:test>
		</xsl:if>
	</xsl:for-each>
	  ){...}
	</xsp:logic>
</xsl:template>

But with this I alway got errors ...

The produced source looks terrible :-)
Something like this:

if (
this.character("...");
this.character("...");
)
...

I know that this can´t compile, but how can I do it the right way?
Can someone help me out, please?


Bye,
  Klaus
-- 
Farewell! I will omit no opportunity
That may convey my greetings, love, to thee.
                                   Romeo&Juliet
                         (Act III, Scene V)
---------------------------------------------
PGP-Key: http://pgp.kdnet.de (soon!)
---------------------------------------------


Re: xsl question

Posted by Klaus Drechsler <dr...@gmx.net>.
Hi,

>  oh well. try this instead:
>
><xsl:template match="mytag:bool | mytag:ok | mytag:error">
>   <xsp:expr><xsl:value-of select="."/></xsp:expr>
></xsl:template>

Thank you very, very much (again). This one works perfectly!

Have a nice day!

Bye,
  Klaus


-- 
Farewell! I will omit no opportunity
That may convey my greetings, love, to thee.
                                   Romeo&Juliet
                         (Act III, Scene V)
---------------------------------------------
PGP-Key: http://pgp.kdnet.de (soon!)
---------------------------------------------


Re: xsl question

Posted by Donald Ball <ba...@webslingerZ.com>.
On Mon, 26 Feb 2001, Klaus Drechsler wrote:

> ><xsl:template match="mytag:content">
> >   <xsp:logic>
> >     if (true
> >     <xsl:for-each select="mytag:bool">
> >       &amp;&amp; <xsl:apply-templates select="."/>
> >     </xsl:for-each>
> >     ) {
> >       <xsl:apply-templates select="mytag:ok"/>
> >     } else {
> >       <xsl:apply-templates select="mytag:error"/>
> >     }
> >   </xsp:logic>
> ></xsl:template>
> >
> ><xsl:template match="mytag:bool | mytag:ok | mytag:error">
> >   <xsl:apply-templates/>
> ></xsl:template>
>
> Thank you for your very fast answer. But this does not work. The produced
> source code looks like this:
>
> ...
>          if (true
>              && this.characters("yourObj.isNew()");
>              && this.characters("myObj.isNew()");) {
>
>          } else
> ...
>
> In the browser window I got the following error message:
>
> Line 0, column 0:
> C:\jakarta-tomcat-4.0-b1\work\localhost\cocoon\_C_\_jakarta_tomcat_4_0_b1\_webapps\_cocoon\_dbprakhouse\_test_xsp.java:352:
> ')' expected. && this.characters("request.getSession(false).isNew()");
> ...
>
> Those semicolons (";") are wrong there ...
>
> It should produce the following sourcecode:
>
> ...
>          if (true
>              && this.characters("yourObj.isNew()")
>              && this.characters("myObj.isNew()")) {
>
>          } else

er, no, it shouldn't be producing the this.characters() method calls even.
looks like the default action for text in that context is to output
characeters - which is odd, i would have thought that since the text's
parent node is xsp:logic, it'd be assumed to be logic. oh well. try this
instead:

<xsl:template match="mytag:bool | mytag:ok | mytag:error">
  <xsp:expr><xsl:value-of select="."/></xsp:expr>
</xsl:template>

but you know, it rather looks like a bug in the c2 xsp engine. anyone want
to take a look? for the record, the xml he wants to use the logicsheet
upon was:

<mytag:content>
        <mytag:bool>myObject.isTrue()</mytag:bool>
        <mytag:bool>yourObject.isTrue()</mytag:bool>
        ...
        <mytag:ok>myObject.someMethod()</mytag:ok>
        <mytag:error>yourObject.someMethod()</mytag:error>
</mytag:content>

- donald


Re: xsl question

Posted by Klaus Drechsler <dr...@gmx.net>.
>...
>...
>         if (true
>             && this.characters("yourObj.isNew()");
>             && this.characters("myObj.isNew()");) {
>
>         } else
>...
>...


I have another question:

Does this produced sourcecode do that what I want?

I would like do something like this:

...
         if (true
             && yourObj.isNew()
             && myObj.isNew()) {

         } else
...

I wonder if both source-codes do the same ...

ciao,
  Klaus
-- 
Farewell! I will omit no opportunity
That may convey my greetings, love, to thee.
                                   Romeo&Juliet
                         (Act III, Scene V)
---------------------------------------------
PGP-Key: http://pgp.kdnet.de (soon!)
---------------------------------------------


Re: xsl question

Posted by Donald Ball <ba...@webslingerZ.com>.
On Mon, 26 Feb 2001, Klaus Drechsler wrote:

> ><xsl:template match="mytag:content">
> >   <xsp:logic>
> >     if (true
> >     <xsl:for-each select="mytag:bool">
> >       &amp;&amp; <xsl:apply-templates select="."/>
> >     </xsl:for-each>
> >     ) {
> >       <xsl:apply-templates select="mytag:ok"/>
> >     } else {
> >       <xsl:apply-templates select="mytag:error"/>
> >     }
> >   </xsp:logic>
> ></xsl:template>
> >
> ><xsl:template match="mytag:bool | mytag:ok | mytag:error">
> >   <xsl:apply-templates/>
> ></xsl:template>
>
> Thank you for your very fast answer. But this does not work. The produced
> source code looks like this:
>
> ...
>          if (true
>              && this.characters("yourObj.isNew()");
>              && this.characters("myObj.isNew()");) {
>
>          } else
> ...
>
> In the browser window I got the following error message:
>
> Line 0, column 0:
> C:\jakarta-tomcat-4.0-b1\work\localhost\cocoon\_C_\_jakarta_tomcat_4_0_b1\_webapps\_cocoon\_dbprakhouse\_test_xsp.java:352:
> ')' expected. && this.characters("request.getSession(false).isNew()");
> ...
>
> Those semicolons (";") are wrong there ...
>
> It should produce the following sourcecode:
>
> ...
>          if (true
>              && this.characters("yourObj.isNew()")
>              && this.characters("myObj.isNew()")) {
>
>          } else

er, no, it shouldn't be producing the this.characters() method calls even.
looks like the default action for text in that context is to output
characeters - which is odd, i would have thought that since the text's
parent node is xsp:logic, it'd be assumed to be logic. oh well. try this
instead:

<xsl:template match="mytag:bool | mytag:ok | mytag:error">
  <xsp:expr><xsl:value-of select="."/></xsp:expr>
</xsl:template>

but you know, it rather looks like a bug in the c2 xsp engine. anyone want
to take a look? for the record, the xml he wants to use the logicsheet
upon was:

<mytag:content>
        <mytag:bool>myObject.isTrue()</mytag:bool>
        <mytag:bool>yourObject.isTrue()</mytag:bool>
        ...
        <mytag:ok>myObject.someMethod()</mytag:ok>
        <mytag:error>yourObject.someMethod()</mytag:error>
</mytag:content>

- donald


Re: xsl question

Posted by Klaus Drechsler <dr...@gmx.net>.
><xsl:template match="mytag:content">
>   <xsp:logic>
>     if (true
>     <xsl:for-each select="mytag:bool">
>       &amp;&amp; <xsl:apply-templates select="."/>
>     </xsl:for-each>
>     ) {
>       <xsl:apply-templates select="mytag:ok"/>
>     } else {
>       <xsl:apply-templates select="mytag:error"/>
>     }
>   </xsp:logic>
></xsl:template>
>
><xsl:template match="mytag:bool | mytag:ok | mytag:error">
>   <xsl:apply-templates/>
></xsl:template>

Thank you for your very fast answer. But this does not work. The produced 
source code looks like this:

...
         if (true
             && this.characters("yourObj.isNew()");
             && this.characters("myObj.isNew()");) {

         } else
...

In the browser window I got the following error message:

Line 0, column 0: 
C:\jakarta-tomcat-4.0-b1\work\localhost\cocoon\_C_\_jakarta_tomcat_4_0_b1\_webapps\_cocoon\_dbprakhouse\_test_xsp.java:352: 
')' expected. && this.characters("request.getSession(false).isNew()");
...

Those semicolons (";") are wrong there ...

It should produce the following sourcecode:

...
         if (true
             && this.characters("yourObj.isNew()")
             && this.characters("myObj.isNew()")) {

         } else
...

Any ideas?

Bye,
  Klaus
-- 
Farewell! I will omit no opportunity
That may convey my greetings, love, to thee.
                                   Romeo&Juliet
                         (Act III, Scene V)
---------------------------------------------
PGP-Key: http://pgp.kdnet.de (soon!)
---------------------------------------------


Re: xsl question

Posted by Donald Ball <ba...@webslingerZ.com>.
On Sun, 25 Feb 2001, Klaus Drechsler wrote:

> I have an xsp page looking something like that:
>
> <mytag:content>
> 	<mytag:bool>myObject.isTrue()</mytag:bool>
> 	<mytag:bool>yourObject.isTrue()</mytag:bool>
> 	...
> 	<mytag:ok>myObject.someMethod()</mytag:ok>
> 	<mytag:error>yourObject.someMethod()</mytag:error>
> </mytag:content>
>
> Now I want a Logicsheet, that takes all <bool>�s and checks if they are all
> "true", eg:
>
> if(myObject.isTrue()&yourObject.isTrue() ... ){
> 	myObject.someMethod();
> }else{
> 	yourObject.someMethod();
> }

<xsl:template match="mytag:content">
  <xsp:logic>
    if (true
    <xsl:for-each select="mytag:bool">
      &amp;&amp; <xsl:apply-templates select="."/>
    </xsl:for-each>
    ) {
      <xsl:apply-templates select="mytag:ok"/>
    } else {
      <xsl:apply-templates select="mytag:error"/>
    }
  </xsp:logic>
</xsl:template>

<xsl:template match="mytag:bool | mytag:ok | mytag:error">
  <xsl:apply-templates/>
</xsl:template>

- donald