Imbrication de plusieurs modèles XSLT conditionnellement

Mon XML est très plat, et en voici un exemple:

<Rows>
  <Row>
    <ProjectID>1000</ProjectID>
    <Phase>Initiation</Phase>
    <ID>1</ID>
    <Name>Work item 1</Name>
    <Master>1</Master>
  </Row>
  <Row>
    <ProjectID>1000</ProjectID>
    <Phase>Initiation</Phase>
    <ID>2</ID>
    <Name>Work item 2</Name>
    <Master>1</Master>
  </Row>
  <Row>
    <ProjectID>1000</ProjectID>
    <Phase>Closing</Phase>
    <ID>3</ID>
    <Name>Work item 3</Name>
    <Master>3</Master>
  </Row>
  <Row>
    <ProjectID>1000</ProjectID>
    <Phase>Closing</Phase>
    <ID>4</ID>
    <Name>Work item 4</Name>
    <Master>3</Master>
  </Row>
  <Row>
    <ProjectID>1000</ProjectID>
    <Phase>Closing</Phase>
    <ID>5</ID>
    <Name>Work item 5</Name>
    <Master>4</Master>
  </Row>
</Rows>

Et ils doivent être imbriqués de telle sorte qu'il affiche en tant que tel:

**Initiation**
Work item 1
  Work item 2
**Closing**
  Work item 3
    Work item 4
      Work item 5

Droit maintenant, j'ai un modèle pour ProjectID, la Phase, et le Nom (par exemple, mon modèle actuel sont assez grandes) et je commence dans le ProjectID modèle, le groupe et la boucle de phase et de groupe et de la boucle de l'étape-par-nom. (Donc, je reçois une liste de tous les noms par phase de projet). Il a travaillé beaucoup pour seulement 2 niveaux (dire le travail de l'un des articles 1 et 2), mais le troisième niveau (comme élément de travail 5) ont perdu moi.

Droit maintenant, j'essaie de faire une itération sur tous les Maître des champs dans le modèle de Nom (dont le vrai code est ici):

<xsl:template name="Deliverable">
<!--
Parent == True && Lone == True -> Impossible
Parent == True && Lone == False -> Parent
Parent == False && Lone == False -> Child
Parent == False && Lone = True -> Single deliverable -->
<xsl:param name="parent" />
<xsl:param name="lone" />
<xsl:variable name="Parent">
<xsl:choose>
<xsl:when test="count(key('project-phase-deliverables', concat(ProjectNo, '|', Phase, '|', IDField2))) > 1">
1
</xsl:when>
<xsl:otherwise>
0
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="ID"><xsl:value-of select="generate-id(IDField1)" /></xsl:variable>
<tr>
<xsl:choose>
<!-- JS for parent deliverable -->
<xsl:when test="$Parent = 'True'">
<xsl:attribute name="ID">
<xsl:value-of select="$ID"/>
</xsl:attribute>
<script>$('#<xsl:value-of select="$ID"/>').click(function() { $('.<xsl:value-of select="IDField2"/>').toggle(); });</script>
</xsl:when>
<!-- Coloring/attributes for children -->
<xsl:when test="$parent = 'False' and $lone='False'">
<xsl:attribute name="style">background: #DEDEFF; display: none;</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="IDField2"/>
</xsl:attribute>
</xsl:when>
</xsl:choose>
<td class="doWhite" style="width: 15px; height: 24px; text-align:right; border-right:none;">
<p class="normal">
<!-- Parent deliverable expander arrow -->
<xsl:if test="$Parent = 1">
<span class="Expander">&#9654;</span>
</xsl:if>
</p>
</td>
<td class="doWhite" style="width: 200px; height: 24px; border-left:none;">
<p class="normal">
<!-- Child deliverable diamond -->
<xsl:if test="$parent = 'False' and $lone = 'False'">
<span class="Expander">&#9670; </span>
</xsl:if>
<xsl:value-of select="ItemDescription"/>
</p>
</td>
<td class="doWhite" style="width: 130px; height: 24px">
<p class="normal">
<xsl:value-of select="Owner"/>
</p>
</td>
<td style="width: 60px; height: 24px">
<xsl:call-template name="status"/>
</td>
<td class="doWhite">
<p class="normal">
<xsl:value-of select="ItemNotes"/>
</p>
</td>
</tr>
<xsl:if test="$Parent = 1">
<xsl:for-each select="key('project-phase-deliverables', concat(ProjectNo, '|', Phase, '|', IDField2))[position()!=1]">
<!-- this doesn't recurse properly :( -->
<xsl:call-template name="Deliverable" />
</xsl:for-each>
</xsl:if>
</xsl:template>

Et comme vous pouvez vous attendre à ce que les boucles à l'infini et de temps. Je sens que je peux utiliser apply-template pour mon problème, mais comment puis-je l'utiliser efficacement en groupe par les autres champs (Phase et ProjectID) ?

OriginalL'auteur Parker | 2011-11-16