You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Rob van der Zeijden <r....@tiscon.de> on 2000/10/25 08:59:52 UTC

compare two variables

Hi,

how can I compare two variables in XSL. For example:

if (nrOfColumns != nrOfColumnsFile)

or

if (nrOfColumns == nrOfColumnsFile)

Thanks.


RE: AW: assigning variable to select attribute

Posted by Per Kreipke <pe...@onclave.com>.
Couple of things:
- shouldn't <xsl:content> be <xsp:content>?
- I guess what you're trying to do is dynamically determine the domain child
to select.
  I'm not sure you can in one pass of the XSP file, but you could try the
following.

Use <xsp:attribute>.

I haven't done this myself, but I think what you might be looking for:

 <fp:write to="external-item">
   <xsp:attribute
name="select">domain[child::<xsp:expr>domainName</xsp:expr></xsp:attribute>
   <xsp:expr>act</xsp:expr>
 </fp:write>

> thanks for reply, but i didn't understand the answer. please read the
> below peace of source code in order to understand my problem. what may i
> assign in the select attribute instead of the variable domainName.
>
> <xsp:logic>
>   Enumeration    e = request.getParameterNames();
>
>    if ((e != null) &amp;&amp; (e.hasMoreElements())) {
>    <xsl:content>
>           <xsp:logic>
>            while (e.hasMoreElements())

>                String domainName = (String) e.nextElement();
>                String act = request.getParameter(domainName);
>
>                if(domainName.indexOf('.')!= -1 ){
>                   <item>
>                      <fp:write
> select="domain[child::name=domainName]/action" to="external-item">
>                      <xsp:expr>act</xsp:expr>
>                      </fp:write>
>                    </item>
>               }
>             }
>             </xsp:logic>
>             </xsl:content>
>     }
> </xsp:logic>


Re: AW: assigning variable to select attribute

Posted by Ehab Jewabreh <e....@bonelabs.com>.
Hi,

thanks for reply, but i didn't understand the answer. please read the
below peace of source code in order to understand my problem. what may i
assign in the select attribute instead of the variable domainName.  

<xsp:logic>
  Enumeration    e = request.getParameterNames(); 

   if ((e != null) &amp;&amp; (e.hasMoreElements())) {
   <xsl:content>
          <xsp:logic>
           while (e.hasMoreElements()) { 
               String domainName = (String) e.nextElement();
               String act = request.getParameter(domainName); 
               
               if(domainName.indexOf('.')!= -1 ){
                  <item>
                     <fp:write
select="domain[child::name=domainName]/action" to="external-item">
                     <xsp:expr>act</xsp:expr>
                     </fp:write>
                   </item>    		       
              }
            }
            </xsp:logic>
            </xsl:content>
    } 
</xsp:logic>


Gabi Brysch wrote:
> 
> hi,
> 
> >>>is there anybody, who can help a cocoon beginner to solve this problem:
> 
> >>>when i assign the variable "domainName" in the select attribute i get a
> >>>null pointer exception.
> 
> >>>domainName ="sun.com";
> >>><fp:write select="domain[child::name=domainName]/action"
> >>>to="external-item">
> >>>                     <xsp:expr>act</xsp:expr>
> >>>                     </fp:write>
> 
> does it work if you don't use a variable like ???
> ...
> <fp:write select="domain[child::name='sun.com']/action" to="external-item">
> ...
> 
> did you use any 'tag' to declare the variable domainName ???
> 
> GABI
> 
> 
> 
> Thanks.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

AW: assigning variable to select attribute

Posted by Gabi Brysch <br...@inxnet.de>.
hi,

>>>is there anybody, who can help a cocoon beginner to solve this problem:

>>>when i assign the variable "domainName" in the select attribute i get a
>>>null pointer exception. 

>>>domainName ="sun.com";
>>><fp:write select="domain[child::name=domainName]/action"
>>>to="external-item">
>>>                     <xsp:expr>act</xsp:expr>
>>>                     </fp:write>


does it work if you don't use a variable like ???
...
<fp:write select="domain[child::name='sun.com']/action" to="external-item">
...

did you use any 'tag' to declare the variable domainName ???

GABI
 


 
Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org



assigning variable to select attribute

Posted by Ehab Jewabreh <e....@bonelabs.com>.
Hello everybody, 

is there anybody, who can help a cocoon beginner to solve this problem:

when i assign the variable "domainName" in the select attribute i get a
null pointer exception. 

domainName ="sun.com";
<fp:write select="domain[child::name=domainName]/action"
to="external-item">
                     <xsp:expr>act</xsp:expr>
                     </fp:write>

 
is it possible to do this?how?

 
Thanks.

Re: compare two variables

Posted by Rob van der Zeijden <r....@tiscon.de>.
Thanks Gaby.


AW: compare two variables

Posted by Gabi Brysch <br...@inxnet.de>.
Hi,

>>>how can I compare two variables in XSL. For example:
>>>if (nrOfColumns != nrOfColumnsFile)

<!-- you can do it with parameters like this -->
<xsl:param name="var1">test</xsl:param>
<xsl:param name="var2">test2</xsl:param>
<xsl:if test="not($test=$test2)">
   <!-- do some action if comparison is true -->
</xsl:if>
or

>>>if (nrOfColumns == nrOfColumnsFile)
<xsl:param name="var1">test</xsl:param>
<xsl:param name="var2">test2</xsl:param>
<xsl:if test="$test=$test2">
   <!-- do some action if comparison is true -->
</xsl:if>

instead of xsl:if, you can use:
<xsl:choose>
	<xsl:when test="$test=$test2>
		<!-- do something if condition is true -->
	</xsl:when>
	<xsl:otherwise>
		<!-- do something if condition is not true -->
	</xsl:otherwise>
</xsl:choose>

i think instead of using xsl:param you can use attributes instead
like:

<xsl:if test="@attribut=$test">
	<!-- do something if true -->
</xsl:if>

i hope with this examples you can go on with xslt !?

bye, GABI


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org