[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

sort to categories

Subject: sort to categories
From: "Markus Hanel" <markus.hanel@xxxxxx>
Date: Thu, 16 Dec 2004 09:56:39 +0100 (MET)
xsl sort by category
hello,

can anyone give my an idea to solve the following problem:
I want to sort some students to the categories: division and group; but the
categories should be flexible and expandable;
at an other time for example school, division and group; they should be
given in a separat xml file;
the output should be in the following way:
division1
  group1
    hauser monika
    wilhelm arno
  group2
    maier martin

division2
  group1
    jonak gert
    walch stefan
  ...

I have managed it with one fixed category, but now i have no ideas!
many thanks,
markus

xml file
<node label="interviewees" status="active" type="interviewee">
  <pers_data id="2" status="active" task="interviewee">
    <url path="/quirxi/qpers_data/2.xml" proto="file"/>
  </pers_data>
  <pers_data id="3" status="active" task="interviewee">
    <url path="/quirxi/qpers_data/3.xml" proto="file"/>
  </pers_data>
  <pers_data id="4" status="active" task="interviewee">
    <url path="/quirxi/qpers_data/4.xml" proto="file"/>
  </pers_data>
  ...
</node>

the pers_data files look like
<pers_data task="interviewee" id="4" status="active">
<surname>Martin</surname>
<lastname>Maierunteregger</lastname>
<group>group1</group>
<division>Innenausbau</division>
<school>htl imst</school>
<userid>c</userid>
<pass>c</pass>
<sex>m</sex>
</pers_data>

stylesheet
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="mod_admin"
select="document('../qxml/a_format_default.xml')/format/modul[attribute::label
= 'interviewer']/files/file[attribute::name = 'qier_group_take_iees']" />

<xsl:template match="/">
<html>
<head><title></title>
</head>
<body>
  <xsl:apply-templates
select="./node[attribute::type='interviewee']/pers_data[attribute::status =
'active']" />
</body>
</html>
</xsl:template>

<xsl:template match="pers_data">
<xsl:variable name="take_category" select="$mod_admin/param[attribute::label
= 'body']/shows/show[position() = last()]" />
<xsl:variable name="select_category"
select="document(./url/@path)/pers_data/*[name()=$take_category]" />
  <xsl:if
test="not(following-sibling::pers_data[document(./url/@path)/pers_data/*[name()=$take_category]
= $select_category)">
        <xsl:apply-templates
select="../descendant::pers_data[document(./url/@path)/pers_data/group =
$select_category]" mode="take">
          <xsl:sort select="document(./url/@path)/pers_data/lastname" />
          <xsl:sort select="document(./url/@path)/pers_data/surname" />
        </xsl:apply-templates>
    </xsl:if>
</xsl:choose>
</xsl:template>

<xsl:template match="pers_data" mode="take">
<div>
  &#160;&#160;&#160;&#160;&#160;
  <xsl:value-of select="document(./url/@path)/pers_data/lastname" />
</div>
</xsl:template>
</xsl:stylesheet>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.