Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL transformation to HTML Question

Status
Not open for further replies.

troyarch

MIS
Mar 12, 2003
29
US
I need to take a list of userIds and translate them into a select list of userIds in an html select list. The end-user will need to be able to select the users in the table and click on a button next to the select list. My main problem is putting the buttons in the xsl because I do not understand what the template should be.

My XML:
<?xml version="1.0" encoding="UTF-8" ?>
<taskManagerRole xmlns="<response xmlns="">
<role>
<role>
<roleId>ee_qualitycontrol</roleId>
<roleName>Performs teamworks process modeling functions</roleName>
</role>
</role>
<currentTaskManagerUsers>
<users>
<user>
<userId>billj</userId>
<firstName>Bill</firstName>
<lastName>Johnson</lastName>
</user>
<user>
<userId>suer</userId>
<firstName>Sue</firstName>
<lastName>Richards</lastName>
</user>
</users>
</currentTaskManagerUsers>

This is my XSL:
<xsl:template match="currentTaskManagerUsers">
<select name="roleAvailable_Select" size="16" style="width:260">
<xsl:for-each select="users/user">
<option>
<xsl:value-of select="userId"/>
</option>
</xsl:for-each>
</select>
</xsl:template>

<xsl:template name="troy">
<td valign="middle" align="center"><br></br>
<input style="width=85px" class="button" name="addB" type="submit" value="Add" />
<br></br><br></br>
<input style="width=85px" class="button" name="removeB" type="submit" value="Remove" /> <br></br>
</td>
</xsl:template>
 
Not sure what you want here. You have a select list populated with userid, then there is a button next to the select list. What does the button do? Maybe it would be best if you posted the HTML output you're looking for.

Jon

"I don't regret this, but I both rue and lament it.
 
The purpose of the page will be to add and remove users from a select list on the left to one on the right. I only gave you part of my code before.

Question: How do I put the buttons in the XSL code?

I would like my resultant html to look like this.
<?xml version="1.0" encoding="UTF-8"?>
<table>
<tr>
<td valign="top"><div class="cslabel">&nbsp;Available Users<BR></div>
<td></td>
<td><div class="cslabel">&nbsp;Assigned Users<br></div>

<tr>
<td>
<select style="width:260" size="16" name="roleCurrent_Select">
<option>Johnson,Bill:billj</option>
<option>Richards,Sue:suer</option>
</select>
</td>

<td valign="middle" align="center"><br>
<input style="width=85px" class="button" name="addB" type="submit" value="Add &gt;" onClick="doAdd(); doOK(); ">
<br><br>

<input style="width=85px" class="button" name="removeB" type="submit" value="&lt; Remove" onClick="doRemove(); doOK();">
<br>
</td>

<td>
<select style="width:260" size="16" name="roleAvailable_Select">
<option>Black,Philip:philipb</option>
<option>Roe,Howard:howardr</option>
</select>
</td>
</tr>
</table>

Thanks.
 
This should just be an XSL question. At this point I don't care if the button works (I need to take this one step at a time to keep myself from becoming too confused). I just want to know the syntax for putting an html button within the XSL file.
 
Well, there might be some things to correct, but basically you just code the <input> element. You indicated that you wanted the following:
Code:
   <input style="width=85px" class="button" name="addB" type="submit" value="Add &gt;" onClick="doAdd(); doOK(); ">
    <br><br>

    <input style="width=85px" class="button" name="removeB" type="submit" value="&lt; Remove" onClick="doRemove(); doOK();">
    <br>

<br> is not correct XHTML. Think <br />. Likewise, remember to close the <input> element. If you are using an HTML editor to create/model your pages, find the 'create XHTML' preference setting.

Also, I am concerned about the value="&lt; Remove". I think this will make it through the transform, but there might be issues to overcome for which you need <xsl:attribute>.

Tom Morrison
 
Thanks Tom. I made the corrections and now I get this error:
javax.xml.transform.TransformerException: br is not allowed in this position in the stylesheet!

When I get rid of the <br /> elements I get a similar error for the <td> element. Any idea?

I took the <input> elements out of the <xsl:template> element. Should they be?
<td valign="middle" align="center"><br />
<input style="width=85px" class="button" name="addB" type="submit" value="Add" onClick="moveOptions(this.form.tw_local_rolesAvailable_Select,this.form.tw_local_rolesAssigned_Select);" />
<br /><br />

<input style="width=85px" class="button" name="removeB" type="submit" value="Remove" onClick="moveOptions(this.form.tw_local_rolesAssigned_Select,this.form.tw_local_rolesAvailable_Select);" />
<br />
</td>
 
I am not familiar with that particular diagnostic, but I would presume that you have placed the <td> in a spot where the XSLT processor was expecting an <xsl:xxxx> element. Check to make sure your <xsl:xxxx> elements are properly closed (especially those opened above the <td>) and correctly encapsulate the <td>...</td>.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top