[xsl] recursive lists displaying grandchildren as children too

Subject: [xsl] recursive lists displaying grandchildren as children too
From: Joelle Tegwen <tegwe002@xxxxxxx>
Date: Tue, 24 Oct 2006 11:46:45 -0500
I want the results to look like this:


More On Going To School <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_index.asp>:

   * Making School Interesting
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_interesting.asp>
   * Knowing What I Have to Do
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_haveToDo.asp>
   * Knowing Things I Want to Do
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_wantToDo.asp>
   * Having a Disability
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_index.asp>

         o Understanding Tests and Accommodations
           <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_tests.asp>
         o My Individuatlized Education Program
           <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_iep_index.asp>

But what I'm getting is this:


More On Going To School <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_index.asp>:

   * Making School Interesting
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_interesting.asp>
   * Knowing What I Have to Do
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_haveToDo.asp>
   * Knowing Things I Want to Do
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_wantToDo.asp>
   * Having a Disability
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_index.asp>

         o Understanding Tests and Accommodations
           <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_tests.asp>
         o My Individuatlized Education Program
           <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_iep_index.asp>
   * Understanding Tests and Accommodations
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_tests.asp>
   * My Individuatlized Education Program
     <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_iep_index.asp>


Notice that "Understanding Tests and Accommodations <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_tests.asp>" and "My Individuatlized Education Program <https://icitest1.education.umn.edu/joelle/yh-2ndhead/highschool/gs_di_iep_index.asp>" are showing up as children of "Going to School" when they're children of "Having a Disability" How do I make them not show up as children of Going to School?


The xml document is here: http://rafb.net/paste/results/TwIVzn94.html . Xsl stylesheet below.

(note: eventually parentID and sectionID will usually be different and they will be dynamically loaded - not that I know how I'm going to do that yet.)

Thanks much
Joelle Tegwen

My stylesheet looks like this:
<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:youth="http://www.youthhood.org";
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:variable name="parentID" select="16" />
<xsl:variable name="sectionID" select="16" />
<xsl:variable name="pSection" select="//youth:section[youth:id=$parentID]/ancestor-or-self::youth:section[last()]"/>


<xsl:variable name="location" select="$pSection/youth:folder"/>


<xsl:template match="youth:sitemap">
<html>
<body>
<h2>More On <a>
<xsl:attribute name="href">
<xsl:value-of select="concat('../', $location,'/', $pSection/youth:section/youth:url)"/>
</xsl:attribute>
<xsl:value-of select="$pSection/youth:section/youth:title" /></a>:</h2>
<ul>
<xsl:apply-templates select="//youth:section[youth:id=$parentID]/descendant::youth:section"/>
</ul>
</body>
</html>
</xsl:template>



<xsl:template match="youth:section">
<li><a>
<xsl:attribute name="href">
<xsl:value-of select="concat('../', $location,'/', youth:url)"/>
</xsl:attribute>
<xsl:value-of select="youth:title" /></a>
<xsl:if test="count(./youth:section) &gt; 0">
<ul>
<xsl:apply-templates select="youth:section"/>
</ul>
</xsl:if>
</li>
</xsl:template>


</xsl:stylesheet>

Current Thread