cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tagunov Anthony" <atagu...@nnt.ru>
Subject Re: xsp in stylesheet isn't being exectued
Date Fri, 16 Mar 2001 20:02:04 GMT
On Fri, 16 Mar 2001 19:04:17 +0100, simone cecchini wrote:

>At 18:35 3/16/01 +0300, you wrote:
>>On Fri, 16 Mar 2001 16:18:44 +0100, simone cecchini wrote:
>>
>>>At 17:38 3/15/01 -0800, you wrote:
>>>
>>>>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)"/>
>>><snip>
>>>
>>>i think your problem is due to the order of execution.
>>>first, you start the xsp processor and then you have a page of the kind:
>>><page>
>>>...
>>></page>
>>>(you can remove the xslt processing-instruction from your xsp page, to verify
this)
>>>then you apply your stylesheet, that turns <encode-this...> into <xsp:expr>
and then... nothing! the xsp processor doesn't get executed anymore, leaving 
>>the xsp.expr tag as it is.
>>>if you apply this modifications
>>>
>>>.xml
>>><?xml version="1.0"?> 
>>><?cocoon-process type="xslt" ?>
>>><?xml-stylesheet href="xsptest.xsl" type="text/xsl"?>
>>
>>err.. did you mean
>><?xml-logicsheet href="xsptest.xsl" type="text/xsl"?>
>>, Simon?
>>
>
>i thought i can use <?xml-stylesheet...> to create an xsp page and get it executed
by the xsp processor. isn't it? 

No, you can't.

(well technicall you can specify in the page
<?cocoon-process type="xslt"?> first
<?xml-stylesheet=".."..?>
<?cocoon-process type="xsp"?> second
but then it would do you no good. nasty things
happen then. it was not meant that any processor 
could preceed xsp
errr.. look at the xsp/cean-page.xml example with C1 does that
that kind of thing
bad i guess this is already a "deprecated" example! 
don't follow it! 
)

instead of doing this replace the in _your_ code
<?xml version="1.0"?> 
<?cocoon-process type="xslt" ?>
<?xml-stylesheet href="xsptest.xsl" type="text/xsl"?>
for
<?xml version="1.0"?> 
<?cocoon-process type="xsp" ?>
<?xml-logicsheet href="xsptest.xsl" type="text/xsl"?>

(running logicsheets is a part of the xsp processor's contract)

>would you mind explaining me what would be the sequence of execution in the case of the
files i put in the last message?

Well, just as in the clean-page.xml example:

you run first xslt processor, it generates a nice xsp page for you then xsp processor runs.
the trouble is that at every next request to the same URL the xslt processor gets launched
again
then xsp processor checks the data of .xml file finds that it is less then the date of .java
and .class
does no recompilation and launches the xsp page class. (The bad thing is the unnecessary pass
of
the xslt processor, well i have a page like that in my app and it takes 2 extra seconds for
each
request) The worse thing is this is not going to be portable to C2

>i had thought that, following the 'reactor model' of cocoon, i could generate a 'multilevel
scheme', in which i could do something like xml ->xsp->xslt->xsp-
>xslt... where '->' stands for 'generates'.

Ooops!! XSP processor twice! A nasty thing! If it all ran as expaceted you would have your
page
recompiled every time it is invoked! Worse then that.. it just won't work!

You can not chain xsp!

It is strongly advised against running xsp not first in the chain. (it gives overhead, it
is not portable to C2)
It is impossible to run xsp over the same page twice (at least processor would try to store
twice into
one file)

this is a good point for FAQ too

Q: I do   xsp->xsl->xsp->.. but my page behaves in unexpected way. What can i do?
A: Never put xsp twice in a chain. It won't work. 

Q: I do   xsl->xsp->.. but my page does not get recompiled when i change my stylesheet
and it takes long to load. What to do?
A: Running xsp some other processor is hack. Try to avoid that. This won't be portalbe to
C2. This has execution overhead

(sorry, right now xml.apache.org is not accessible from my comp, so i can't check if it is
in the faq already)

P.S. writing this all i consider that you have taken a look at 

>Try putting
>
><?cocoon-process type="linkencode"?>

and if fits your needs better then this all discussion is just about good programming practice
in C1.

>
>.xml
><?xml version="1.0"?> 
><?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>
>
>.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">
> <xsl:processing-instruction name="cocoon-process">type="xsp"</xsl:processing-instruction>
>    <xsl:copy>     <xsl:apply-templates/>    </xsl:copy>
></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>
>  
><xsl:template match="@*|node()" priority="-1">
> <xsl:copy>
>  <xsl:apply-templates select="@*|node()"/>
> </xsl:copy>
></xsl:template>
>  
></xsl:stylesheet>
>
>bye,
>simone
>
>---------------------------------------------------------------------
>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>
>
>


Best regards, 
   Tagunov Anthony



---------------------------------------------------------------------
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