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!

Need Help - XSLT 2.0

Status
Not open for further replies.

jtrembla

ISP
Jul 6, 2006
104
US
I am trying to do unique groupings of department codes from an xml file. I am having 0 luck. I just want a unique set of dept codes from the entire file. This is my code thus far and this needs to be done in 2.0

xslt code
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] version="2.0">
<xsl:output method="html" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>[/URL]


<xsl:template match="/">
<html>
<head><title>jjsjsj</title>
</head>

<body>
<h1>Departments</h1>
<xsl:apply-templates />
</body>
</html>
</xsl:template>

<xsl:template match="/fas_courses/course">

<xsl:for-each-group select="department" group-by="@code">
<xsl:sort select="@code"/>

<xsl:value-of select="current-grouping-key()"/>

<xsl:apply-templates select="current-group()"/>
</xsl:for-each-group>


</xsl:template>


</xsl:stylesheet>






Here is some of the code in the source file

Code:
<fas_courses>
  <course acad_year="2005" cat_num="0802" offered="Y">
    <term term_pattern_code="1" fall_term="Y" spring_term="N">fall term</term>
    <department code="AAAS"/>
    <course_group code="AFRAMER">African and African American Studies</course_group>
    <course_number>
      <num_int>10</num_int>
    </course_number>
    <title>Introduction to African and African American Studies</title>
    <course_type>Lecture with sections</course_type>
    <course_level code="P">Primarily for Undergraduates</course_level>
    <credit code="1">Half course</credit>
    <meeting_text>M., W., (F.), at 11;</meeting_text>
    <faculty_text>Evelynn M. Hammonds</faculty_text>
    <description>An exploration of some of the key texts and issues in African and African American Studies from a range of disciplinary perspectives. Members of the faculty deliver guest lectures in their own areas of specialization.</description>
    <prerequisites/>
    <notes>Required of concentrators. Students who transfer into the concentration after their sophomore year may substitute another African and African American Studies course already taken if they satisfy the Director of Undergraduate Studies that it establishes a basic familiarity with the materials covered in African and African American Studies 10. This course, when taken for a letter grade, meets the Core area requirement for Historical Study A.</notes>
    <instructor_approval_required>N</instructor_approval_required>
    <faculty_list>
      <faculty term="1" role="H" id="F9b646eb3d2749ee30a6154c8b1c2b4f6">
        <name>
          <prefix/>
          <first>Evelynn</first>
          <middle>M.</middle>
          <last>Hammonds</last>
          <suffix/>
        </name>
      </faculty>
    </faculty_list>
    <schedule>
      <meeting term="1" optional="N" type="Lecture" day="1" begin_time="1100" end_time="1200"/>
      <meeting term="1" optional="N" type="Lecture" day="3" begin_time="1100" end_time="1200"/>
      <meeting term="1" optional="Y" type="Lecture" day="5" begin_time="1100" end_time="1200"/>
    </schedule>
    <meeting_locations>
      <location term="1" building="Sever Hall" room="202"/>
    </meeting_locations>
  </course>
  <course acad_year="2005" cat_num="2048" offered="Y">
    <term term_pattern_code="1" fall_term="Y" spring_term="N">fall term</term>
    <department code="AAAS"/>
    <course_group code="AFRAMER">African and African American Studies</course_group>
    <course_number>
      <num_int>20</num_int>
    </course_number>
    <title>Introduction to African Languages and Cultures</title>
    <course_type>Lecture</course_type>
    <course_level code="P">Primarily for Undergraduates</course_level>
    <credit code="1">Half course</credit>
    <meeting_text>M., W., F., at 2</meeting_text>
    <faculty_text>John M. Mugane</faculty_text>
    <description>An introduction to African languages and cultures. Explores language use by sub-Saharan Africans to understand, organize, and transmit indigenous knowledge to successive generations. Language serves as a road map to understanding how social, political, and economic institutions and processes develop: from kinship structures, the evolution of political offices, trade relations, to the transfer of environmental knowledge.</description>
    <prerequisites/>
    <notes/>
    <instructor_approval_required>N</instructor_approval_required>
    <faculty_list>
      <faculty term="1" role="H" id="F8991604883a4ca2601298f8ea013b389">
        <name>
          <prefix/>
          <first>John</first>
          <middle/>
          <last>Mugane</last>
          <suffix/>
        </name>
      </faculty>
    </faculty_list>
    <schedule>
      <meeting term="1" optional="N" type="Lecture" day="1" begin_time="1400" end_time="1500"/>
      <meeting term="1" optional="N" type="Lecture" day="3" begin_time="1400" end_time="1500"/>
      <meeting term="1" optional="N" type="Lecture" day="5" begin_time="1400" end_time="1500"/>
    </schedule>
    <meeting_locations>
      <location term="1" building="Barker Center - Union/Burr" room="024"/>
    </meeting_locations>
  </course>
  <course acad_year="2005" cat_num="7010" offered="Y">
    <term term_pattern_code="3" fall_term="Y" spring_term="Y">fall term; repeated spring term</term>
    <department code="AAAS"/>
    <course_group code="AFRAMER">African and African American Studies</course_group>
    <course_number>
      <num_int>90</num_int>
      <num_char>r</num_char>
    </course_number>
    <title>African Language Tutorials</title>
    <course_type>Tutorial</course_type>
    <course_level code="P">Primarily for Undergraduates</course_level>
    <credit code="1">Half course</credit>
    <meeting_text>Hours to be arranged.</meeting_text>
    <faculty_text>John M. Mugane and Nike S. Lawal</faculty_text>
    <description>Individualized study of an African language at the elementary level. Contact hours with language coach. Emphasis on written expression, reading comprehension and oral fluency. The following languages can be taken: Bambara, Hausa, Igbo, Malagasy, and Zulu.</description>
    <prerequisites/>
    <notes>For instruction in languages that are not listed, please consult the Director of the African Language Program. Not open to auditors.</notes>
    <instructor_approval_required>Y</instructor_approval_required>
    <faculty_list>
      <faculty term="1" role="H" id="F8991604883a4ca2601298f8ea013b389">
        <name>
          <prefix/>
          <first>John</first>
          <middle/>
          <last>Mugane</last>
          <suffix/>
        </name>
      </faculty>
      <faculty term="1" role="O" id="F4f923a259118818ebf1eca27e73e8aed">
        <name>
          <prefix/>
          <first>Nike</first>
          <middle>S.</middle>
          <last>Lawal</last>
          <suffix/>
        </name>
      </faculty>
      <faculty term="2" role="H" id="F8991604883a4ca2601298f8ea013b389">
        <name>
          <prefix/>
          <first>John</first>
          <middle/>
          <last>Mugane</last>
          <suffix/>
        </name>
      </faculty>
      <faculty term="2" role="O" id="F4f923a259118818ebf1eca27e73e8aed">
        <name>
          <prefix/>
          <first>Nike</first>
          <middle>S.</middle>
          <last>Lawal</last>
          <suffix/>
        </name>
      </faculty>
    </faculty_list>
    <schedule/>
    <meeting_locations/>
  </course></fas_courses>
 
To get proper outcome, I suspect, of what you want, change the match/select.

><xsl:template match="/fas_courses/course">
><xsl:for-each-group select="department" group-by="@code">
[tt]
<xsl:template match="/fas_courses">
<xsl:for-each-group select="course/department" group-by="@code">
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top