View Single Post
  #1 (permalink)  
Old May 23rd, 2006, 02:31 PM
cristtiah cristtiah is offline
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl:key doesnt work

<xsl:key name="b" match="Field/@label" use="."/>
<xsl:key name="c" match="Field/@type" use="."/>


....

<xsl:template name="generate-top-elements">

<tr>
<xsl:for-each select="//@label[generate-id(.)=generate-id(key('b',.)[1])]">
  <td><xsl:value-of select="."/></td>

</xsl:for-each>
</tr>
....

<xsl:for-each select="//@type[generate-id(.)=generate-id(key('c',.)[1])]">
    <td><xsl:value-of select="."/>

....

</xsl:template>

and an xml

<Fields>
<Field type="Separator" title="Account Setup" start="yes" pos="top"/>
<Field type="TextBox" label="First Name"></Field>
<Field type="TextBox" label="Middle Name"></Field>
<Field type="TextBox" label="Last Name"></Field>
<Field type="End"/>
<Field type="Separator" title="Investments" pos="level"/>
<Field type="DropDownList" label="Primary Service Type"></Field>
...

and the output

<table>
<tr>
<td>Account Setup</td>
</tr>
</table>
<table>
<tr>
<td>First Name</td>
<td>Middle Name</td>
<td>Last Name</td>
<td>Primary Service Type</td>
<td>Traits</td>
</tr>
<tr>
<td>First Name</td>
<td>Middle Name</td>
<td>Last Name</td>
<td>Primary Service Type</td>
<td>Traits</td>
</tr>
<tr>
<td>First Name</td>
<td>Middle Name</td>
<td>Last Name</td>
<td>Primary Service Type</td>
<td>Traits</td>
</tr>
</table>

<table>
<tr>
<td>Investments</td>
</tr>
</table>
<table>
<tr>
<td>Primary Service Type</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Traits</td>
<td></td>
<td></td>
</tr>
</table>


but should be

<table>
<tr>
<td>Account Setup</td>
</tr>
</table>
<table>
<tr>
<td>First Name</td>
<td>Middle Name</td>
<td>Last Name</td>
</tr>
<tr>
<td>TextBox</td>
<td>TextBox</td>
<td>TextBox</td>
</tr>
</table>

<table>
<tr>
<td>Investments</td>
</tr>
</table>
<table>
<tr>
<td>Primary Service Type</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Traits</td>
<td></td>
<td></td>
</tr>
</table>


is there a way I could put a condition on the key? thanks