You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ca...@cm.be on 2003/06/02 15:52:42 UTC
passing parameters to xsp files
Hi,
Currently I'm working on a web application that uses an Oracle 8i database,
Cocoon 2.0, Tomcat 4.1 and Apache 2.0. I'm using XSP to query, insert and
update my database.
Now I stumbled upon the following problem. I've searched the web for
answers, but even Google wasn't able to help me. So you guys and girls are
my last hope. ;-)
Using XSP want to update a table in my database. So far, no problems. This
is the relevant section in the sitemap:
<!--updating the different columns of the element -->
<map:match pattern="update/*.xml">
<map:generate type="xsp" src="xsp/select/{1}.xsp"/>
<map:transform src="xslt/update/{1}.xslt"/>
<map:transform type="cinclude"/>
<map:serialize type="html"/>
</map:match>
<!-- update application form processing -->
<map:match pattern="form/update-application">
<map:act type="form-validator">
<map:parameter name="descriptor"
value="context:///DIS/database/validate/insert-application.xml"/>
<map:parameter name="validate-set"
value="insert-application"/>
<!-- if success -->
<map:generate type="xsp"
src="xsp/update/update-application.xsp"/>
<map:transform src="xslt/succes_update.xslt"/>
<map:serialize type="html"/>
</map:act>
<!-- if fail -->
<map:read src="html/error.html" mime-type="text/html"/>
</map:match>
<map:match pattern="include/owner.xml">
<map:generate type="xsp" src="xsp/owner.xsp"/>
<map:transform src="xslt/include/owner.xslt"/>
<map:serialize type="html"/>
</map:match>
I've also attached the relevant xslt and xsp files.
As you can see, I include the transformed owner.xsp file in my
application.xsp file. I do this, because I want my users to have a drop down
box with them showing all the possible foreign keys. This way they can never
make a mistake updating foreign keys in the database.
This all works fine, updating and everything. Except for this: I want the
right foreign key selected in my form. I cannot expect my users to select
the right owner in the drop down box everytime they do an update. So I want
to tell the owner.xsp file the owner_id of the application.xsp file that
includes it. A simple test in the owner.xslt should then do the trick. I
know it is possible to pass parameters through the sitemap, but in this case
I want the contents of my parameter to be dependent on the contents of my
xsp file. I don't know how to do this. I don't even know if I'm thinking in
the right direction.
Can you please help me on this? Thanks!
Carolien Coenen
<<application.xslt>> <<application.xsp>> <<owner.xslt>> <<owner.xsp>>
Re: passing parameters to xsp files
Posted by Alexander Schatten <al...@gmx.at>.
Carolien.Coenen@cm.be wrote:
> This all works fine, updating and everything. Except for this: I want
> the right foreign key selected in my form. I cannot expect my users to
> select the right owner in the drop down box everytime they do an
> update. So I want to tell the owner.xsp file the owner_id of the
> application.xsp file that includes it. A simple test in the owner.xslt
> should then do the trick. I know it is possible to pass parameters
> through the sitemap, but in this case I want the contents of my
> parameter to be dependent on the contents of my xsp file. I don't know
> how to do this. I don't even know if I'm thinking in the right direction.
>
> Can you please help me on this? Thanks!
>
I am not sure whether I do understand the problem precisely, but you
know, that you can make cascaded transformations?
I mean something like: XSP-->XSLT-->SQL Transformer--->XSLT--->Serializer
So then you could prepare the stuff in the XSP, then use the SQL
transformer to get the detail information and finally put it all together.
I am not really sure, whether this helps, but maybe you get a new idea.
alex
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
Re: passing parameters to xsp files
Posted by Steven Noels <st...@outerthought.org>.
On 2/06/2003 15:52 Carolien.Coenen@cm.be wrote:
> This all works fine, updating and everything. Except for this: I want
> the right foreign key selected in my form. I cannot expect my users to
> select the right owner in the drop down box everytime they do an update.
> So I want to tell the owner.xsp file the owner_id of the application.xsp
> file that includes it. A simple test in the owner.xslt should then do
> the trick. I know it is possible to pass parameters through the sitemap,
> but in this case I want the contents of my parameter to be dependent on
> the contents of my xsp file. I don't know how to do this. I don't even
> know if I'm thinking in the right direction.
I might be totally off-hook, but did you know there is a
get-sitemap-parameter tag in the xsp-util logicsheet?
</Steven>
--
Steven Noels http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://blogs.cocoondev.org/stevenn/
stevenn at outerthought.org stevenn at apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org
RE: passing parameters to xsp files
Posted by Vindevogel - van Loco <vi...@skynet.be>.
passing parameters to xsp filesHi Carolien,
I guess you want something like this .....
(I did it in plain xml/xsl, didn't find the time to use cocoon on this one,
but it's a working sample.
Where I use the document function in XSL, you should put the values you
cincluded ....)
I made 2 xml files (BillGates.xml and JenniferLopez.xml)
I have one file to fill the comboboxes with the "Gender" attribute.
I then transform the files into HTML using the fourth file, the Client.xsl.
As you will see, the genders are depicted correctly for both (as far as I
know)
The code that really does it is this ...
<select>
<xsl:for-each select="document('genders.xml')/xml/gender">
<option value="@id" >
<xsl:if test="@id = /xml/client/gender">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>
<xsl:value-of select="@description"/>
</option>
</xsl:for-each>
</select>
I think this will solve your problem, as your comboboxes are put on the
value they already had ....
Regards,
Yves Vindevogel
-----Original Message-----
From: Carolien.Coenen@cm.be [mailto:Carolien.Coenen@cm.be]
Sent: maandag 2 juni 2003 15:53
To: cocoon-users@xml.apache.org
Subject: passing parameters to xsp files
Hi,
Currently I'm working on a web application that uses an Oracle 8i
database, Cocoon 2.0, Tomcat 4.1 and Apache 2.0. I'm using XSP to query,
insert and update my database.
Now I stumbled upon the following problem. I've searched the web for
answers, but even Google wasn't able to help me. So you guys and girls are
my last hope. ;-)
Using XSP want to update a table in my database. So far, no problems. This
is the relevant section in the sitemap:
<!--updating the different columns of the element -->
<map:match pattern="update/*.xml">
<map:generate type="xsp" src="xsp/select/{1}.xsp"/>
<map:transform src="xslt/update/{1}.xslt"/>
<map:transform type="cinclude"/>
<map:serialize type="html"/>
</map:match>
<!-- update application form processing -->
<map:match pattern="form/update-application">
<map:act type="form-validator">
<map:parameter name="descriptor"
value="context:///DIS/database/validate/insert-application.xml"/>
<map:parameter name="validate-set"
value="insert-application"/>
<!-- if success -->
<map:generate type="xsp"
src="xsp/update/update-application.xsp"/>
<map:transform src="xslt/succes_update.xslt"/>
<map:serialize type="html"/>
</map:act>
<!-- if fail -->
<map:read src="html/error.html" mime-type="text/html"/>
</map:match>
<map:match pattern="include/owner.xml">
<map:generate type="xsp" src="xsp/owner.xsp"/>
<map:transform src="xslt/include/owner.xslt"/>
<map:serialize type="html"/>
</map:match>
I've also attached the relevant xslt and xsp files.
As you can see, I include the transformed owner.xsp file in my
application.xsp file. I do this, because I want my users to have a drop down
box with them showing all the possible foreign keys. This way they can never
make a mistake updating foreign keys in the database.
This all works fine, updating and everything. Except for this: I want the
right foreign key selected in my form. I cannot expect my users to select
the right owner in the drop down box everytime they do an update. So I want
to tell the owner.xsp file the owner_id of the application.xsp file that
includes it. A simple test in the owner.xslt should then do the trick. I
know it is possible to pass parameters through the sitemap, but in this case
I want the contents of my parameter to be dependent on the contents of my
xsp file. I don't know how to do this. I don't even know if I'm thinking in
the right direction.
Can you please help me on this? Thanks!
Carolien Coenen
<<application.xslt>> <<application.xsp>> <<owner.xslt>> <<owner.xsp>>