<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>
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: maandag 2 juni 2003 15:53
To: [EMAIL PROTECTED]
Subject: passing parameters to xsp filesHi,
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=""/>
<map:transform src=""/>
<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=""/>
<map:transform src=""/>
<map:serialize type="html"/>
</map:act>
<!-- if fail -->
<map:read src="" mime-type="text/html"/>
</map:match>
<map:match pattern="include/owner.xml">
<map:generate type="xsp" src=""/>
<map:transform src=""/>
<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>>
<?xml version="1.0" encoding="UTF-8"?> <xml> <gender id="1" description="Male"/> <gender id="2" description="Female"/> <!--You must be open minded .... --> <gender id="3" description="Unknown"/> </xml>
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="C:\Documents and Settings\Administrator\Desktop\Client.xslt"?> <xml> <client> <name>Gates</name> <firstname>William</firstname> <gender>1</gender> </client> </xml>
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="C:\Documents and Settings\Administrator\Desktop\Client.xslt"?> <xml> <client> <name>Lopez</name> <firstname>Jennifer</firstname> <gender>2</gender> </client> </xml>
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/xml">
<html>
<body>
<table>
<tr>
<td style="width: 100px">Name:</td>
<td><xsl:value-of select="client/name"/></td>
</tr>
<tr>
<td style="width: 100px">First Name:</td>
<td><xsl:value-of select="client/firstname"/></td>
</tr>
<tr>
<td style="width: 100px">Gender:</td>
<td>
<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></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
