You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Benoît Clouet <b....@free.fr> on 2002/07/05 10:50:44 UTC
Use of XSP actions
Hi,
I'm trying to use XSP actions in place of actions written i Java.
I recently discovered the way to set success/failure of actions, but I
still have problems setting a defined result in order to use it later in
the sitemap.
Here is the sitemap fragment :
<map:match pattern="objdoc*">
<map:act type="session-is-valid">
<!-- THIS ACTION SHOULD SET THE VARIABLE objchm IN PLACE OF
THE ACTION objdoc BELOW -->
<map:act type="xsp-action" src="obj/objdoc_act.xsp">
<map:act type="objdoc">
<!-- HERE THE PATH objchm TO THE RESOURCE IS SET
BY AN ACTION WRITTEN IN JAVA THAT I WOULD LIKE TO SQUEEZE
BECAUSE IT USES SESSION OBJECT THE IDEA IS TO USE THE XSP ACTION
PREVIOUSLY DEFINED -->
<map:read type="resource"
mime-type="application/msword"
src="/home/bcl/f_phb2/DocTech/{objchm}.DOC"/>
</map:act>
</map:act>
<!-- chemin dépendant de l'installation -->
<map:read src="/home/bcl/f_phb2/DocTech/pasdocumente.html"/>
<!--map:read src="/home/benoit/DocTech/pasdocumente.html"/-->
</map:act>
<map:redirect-to uri="utlaut"/>
</map:match>
The idea would be to use the <action:set-result/> tag but when I use it
I get a : stylesheet directed termination error.
The XSP page follows :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page
xmlns:xsp="http://apache.org/xsp"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
xmlns:log="http://apache.org/xsp/log/2.0"
xmlns:xsp-session="http://apache.org/xsp/session/2.0"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:action="http://apache.org/cocoon/action/1.0">
<xsp:logic>
String normaliserChapitre(String chapitre)
{// Formater le chapitre pour qu'il corresponde
// à la norme en vigueur pour le nom de fichier
String niveau1, niveau2, niveau3;
System.out.println("Chap :" + chapitre);
niveau1 = chapitre.substring(0, chapitre.indexOf('.'));
niveau2 = chapitre.substring(chapitre.indexOf('.')+1,
chapitre.lastIndexOf('.'));
niveau3 = chapitre.substring(chapitre.lastIndexOf('.')+1);
System.out.println(niveau1 + " : " + niveau2 + " : " + niveau3);
if (Integer.parseInt(niveau1)<10)
niveau1 = "0"+ niveau1;
if (Integer.parseInt(niveau2)<10)
niveau2 = "0"+ niveau2;
if (Integer.parseInt(niveau3)<10)
niveau3 = "0"+ niveau3;
// Retourner ce chapitre
return niveau1 + "." + niveau2 + "." + niveau3;
}
</xsp:logic>
<page>
<esql:connection>
<esql:pool>srvdoc</esql:pool>
<esql:execute-query>
<esql:query>
<!-- Chapitre -->
select crtcod, crtval
from svprj_d001.crtobj
where crtref= '<xsp-request:get-parameter name="prjcod"/>'
and crtrf1= '<xsp-request:get-parameter name="objcod"/>'
and crtcod='TAB-02'
</esql:query>
<esql:results>
<esql:row-results>
<esql:query>
<!-- Domaine -->
select crtcod, crtval
from svprj_d001.crtobj
where crtref= '<xsp-request:get-parameter name="prjcod"/>'
and crtrf1= '<xsp-request:get-parameter name="objcod"/>'
and crtcod='OBJ-21'
</esql:query>
<esql:results>
<esql:row-results>
<action:set-success/>
<!-- HERE I SET THE ACTION RESULT IN A WAY THAT DOESN'T WORK -->
<action:set-result>
<name>chemin</name>
<value>
<xsp-request:get-parameter name="prjcod"/>/<esql:get-string
column="crtval"/>/<xsp:expr>normaliserChapitre(<esql:get-string
column="crtval"
ancestor="1"/>.trim())</xsp:expr>_<xsp-request:get-parameter
name="objcod"/>
</value>
</action:set-result>
</esql:row-results>
</esql:results>
<esql:no-results>
<action:set-failure/>
</esql:no-results>
</esql:row-results>
</esql:results>
<esql:no-results>
<action:set-failure/>
</esql:no-results>
</esql:execute-query>
</esql:connection>
</page>
</xsp:page>
If someone knows the syntax for both the sitemap and the action, it
would help me a lot.
Regards,
Benoît CLOUET
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>