cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piroumian, Konstantin" <KPiroum...@flagship.ru>
Subject Re: xsp in stylesheet isn't being exectued
Date Fri, 16 Mar 2001 08:59:29 GMT
Try this:
<xsl:value-of select="java:java.net.URLEncoder.encode({$testit})"/>
You have to put params and variables into { and } when using in
attribute values.
 
Regards,
    Konstantin Piroumian.

----- Original Message ----- 
From: Vorbau, Alex <mailto:alex_vorbau@hp.com>  
To: 'cocoon-users@xml.apache.org' <mailto:'cocoon-users@xml.apache.org'>

Sent: Friday, March 16, 2001 4:38 AM
Subject: xsp in stylesheet isn't being exectued


Hello,
 
I'm trying to include a small bit of java XSP code in my stylesheet so I
can URL-encode a variable, but the XSP code isn't executing.  BTW, I've
already tried this:
 
<xsl:value-of select="java:java.net.URLEncoder.encode($testit)"/>
 
But the value it returns is blank.  Putting $testit in quotes encodes
the literal string into %24testit, instead of the contents of the
variable.  Ideas around this would be helpful too.
 
Following the XSP examples that come with cocoon, I came up with this
XSP code.  What am I doing wrong?  It seems to be ignoring the xsp: tags
and output the java code.  The resulting page is this:
--------------------------------------------
This should be url-encoded:
java.net.URLEncoder.encode( "you&me" ) 
But it's not! 

--------------------------------------------
xsptest.xml:
 
<?xml version="1.0"?> 
<?cocoon-process type="xsp" ?>
<?cocoon-process type="xslt" ?>
<?xml-stylesheet href="xsptest.xsl" type="text/xsl"?>
 
<xsp:page language="java"
xmlns:xsp="http://www.apache.org/1999/XSP/Core">
<page> 
 <p>
  This should be url-encoded:<br/> <encode-this string="you&amp;me"/>
<br/>
  But it's not!
 </p>

 This works, but I want to do this in the .xsl file:<br/>
 <xsp:expr>
      java.net.URLEncoder.encode( "frankie&amp;johnny" )
 </xsp:expr>
 
</page>
</xsp:page>
 

--------------------------------------------
xsptest.xsl:
 
<?xml version="1.0" ?>
 
<xsl:stylesheet
   xmlns:xsp="http://www.apache.org/1999/XSP/Core"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
 
<xsl:variable name="testit">tony&amp;Alba's!!</xsl:variable>
 
<xsl:template match="xsp:page">
 <xsp:page xmlns:xsp="http://www.apache.org/1999/XSP/Core">
    <xsl:copy>     <xsl:apply-templates/>    </xsl:copy>
 </xsp:page>
</xsl:template>
 
<xsl:template match="page">
<html><body>     <xsl:apply-templates/></body></html>
</xsl:template>
 

<xsl:template match="encode-this">
 <xsp:expr>
    java.net.URLEncoder.encode( "<xsl:value-of select="@string" />" )
 </xsp:expr>
</xsl:template>
 
<!-- passes through the html content -->
<xsl:template match="@*|node()" priority="-1">
 <xsl:copy>
  <xsl:apply-templates select="@*|node()"/>
 </xsl:copy>
</xsl:template>
 
</xsl:stylesheet>

 
-----
Alex Vorbau
HP Labs, Internet & Mobile Systems Lab
650-857-3050
alex_vorbau@hp.com <mailto:alex_vorbau@hp.com> 
 



  _____  




---------------------------------------------------------------------
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: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message