XSLT handling same XML node in different ways in different places of the HTML document -


i want have template creating table of contents @ top of html document, , want able click each item in table more detailed information it, is, jumps appropriate detailed section further down in document.

sort of like:

table of contents:

node1 (clicking takes bolded node1 below)

node2

node3

other stuff ... ...

node1

description: blah

content: 1.55

version: 1.55

rough xslt code:

// create table of contents <table border="1"> <tr bgcolor="#9acd32">     <th style="text-align:left">name</th> </tr> <xsl:for-each select="">     <xsl:apply-templates select="my_node"/> </xsl:for-each>  // other stuff  // create detailed view (code omitted because don't know how yet)  // template node <xsl:template match="my_node">     <tr>         <td><xsl:value-of select="../@name"/></td>     </tr> </xsl:template> 

my problem want handle node twice in different places in code, 1 grab name , 1 grab information. understand it, having 1 template each node preferred practice in xslt. how can achieve describing here?

do pass sort of boolean parameter determine action take inside template? or write template parent node , traverse down name in first case? i'm not sure either of those.

use modes. roughly:

<xsl:template match="/">      <!--  create table of contents -->     <table border="1">         <tr bgcolor="#9acd32">             <th style="text-align:left">name</th>         </tr>         <xsl:apply-templates select="my_node" mode="toc"/>     </table>      <!-- other stuff -->      <!-- create detailed view  -->     <h1>details</h1>     <xsl:apply-templates select="my_node"/> </xsl:template>  <xsl:template match="my_node" mode="toc">     <tr>         <td><xsl:value-of select="../@name"/></td>     </tr> </xsl:template>  <xsl:template match="my_node">     <!-- whatever required detailed view --> </xsl:template> 

p.s. careful mixing xsl:for-each xsl:apply templates. in cases, want use either 1 or other.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -