Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8693921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:39:24+00:00 2026-06-13T00:39:24+00:00

I am trying to make a crosstab tables from the XML file from ToDoList

  • 0

I am trying to make a crosstab tables from the XML file from ToDoList (http://www.abstractspoon.com/tdl_resources.html) Here is an example XML file:

<?xml version="1.0" encoding="utf-16" ?>
<TODOLIST PROJECTNAME="Projects">
    <TASK TITLE="proj1" ID="1" NUMPERSON="1" PERSON="Chris" NUMTAGS="1" TAG="Caro" CALCTIMEESTIMATE="36"/>
    <TASK TITLE="proj2" ID="2" NUMPERSON="1" PERSON="Chris" NUMTAGS="1" TAG="Nat" CALCTIMEESTIMATE="8" />
    <TASK TITLE="proj4" ID="4" NUMPERSON="1" PERSON="Chris" NUMTAGS="1" TAG="Caro" CALCTIMEESTIMATE="36" />
    <TASK TITLE="proj5" ID="5" NUMPERSON="1" PERSON="Sahb" NUMTAGS="1" TAG="Nat" CALCTIMEESTIMATE="128" />
    <TASK TITLE="proj32" ID="32" NUMPERSON="2" PERSON="Seb" PERSON1="Chris" NUMTAGS="1" TAG="Nat" CALCTIMEESTIMATE="0.90" />
</TODOLIST>

Each task is an element and all the info are attributes. I want to make a table like this with the tags as the top row and the persons as the first column.

<table>
    <tr>
        <td></td>
        <td>Caro</td>
        <td>Nat</td>
    </tr>
    <tr>
        <td>Chris</td>
        <td>72</td>
        <td>8</td>
    </tr>
    <tr>
        <td>Sahb</td>
        <td>128</td>
        <td>0</td>
    </tr>
    <tr>
        <td>Seb, Chris</td>
        <td>0</td>
        <td>9</td>
    </tr>
</table>

As you can see the same person can have many projects and I want to add up the CALCTIMEESTIMATE for each person based on the tag(s). I can get the first row with

<xsl:key name="dtag" match="/TODOLIST/TASK/@TAG" use="." />
<xsl:for-each select="TASK/@TAG[generate-id() = generate-id(key('dtag', .)[1])]">
    <td>
      <xsl:value-of select="."/>
    </td>
</xsl:for-each>

But the sum function does not give the desired results. What I’m I missing? Is there an easy way to do the sum based on two attributes? ToDoList uses XSLT 1.0, that’s why I couldn’t use distinct-values.

Here is the full XSLT, I’ve tried alot of different thing, Here I was trying to get it working just for Chris but it would not add up his 2 projects.

<xsl:template match="TODOLIST">
<xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html&gt;</xsl:text>
<html>
<head>
<title>Projects..</title>
</head>
<body>
<table>
<caption>Projects..</caption>
<thead>
<tr>
<td></td>

<xsl:for-each select="TASK/@TAG[generate-id() = generate-id(key('dtag', .)[1])]">
    <th scope="col">
      <xsl:value-of select="."/>
    </th>
</xsl:for-each>

</tr>
</thead>
<tbody>
<xsl:apply-templates select="TASK/@PERSON[generate-id() = generate-id(key('dperson', .)[1])]" />
</tbody>
</table>
</body>
</html>
</xsl:template>

<xsl:template match="TASK/@PERSON">
    <tr>
        <th scope="row">
          <xsl:value-of select="."/>
        </th>
        <xsl:apply-templates select="/TODOLIST/TASK/@TAG[generate-id() = generate-id(key('dtag', .)[1])]" />
    </tr>
</xsl:template>

<xsl:template match="/TODOLIST/TASK/@TAG">
    <td>
        <xsl:value-of select="sum(../@CALCTIMEESTIMATE[../@PERSON = 'Chris'])" />
    </td>
</xsl:template>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:39:26+00:00Added an answer on June 13, 2026 at 12:39 am

    To get your sum to work, you need to know both the current person and the current tag.

    In your current template that matches TASK/@PERSON, you should pass the current value of the attribute to the next template

    <xsl:apply-templates 
       select="/TODOLIST/TASK/@TAG[generate-id() = generate-id(key('dtag', .)[1])]">
         <xsl:with-param name="PERSON" select="." />
    </xsl:apply-templates>
    

    Then, in your template that matches @TAG, you could access the ‘dperson’ key in the SUM, so you sum all tasks for that person, and for the current tag, like so:

    <xsl:template match="/TODOLIST/TASK/@TAG">
      <xsl:param name="PERSON" />
      <td>
        <xsl:value-of 
          select="sum(key('dperson', $PERSON)[../@TAG = current()]/../@CALCTIMEESTIMATE)"/>
      </td>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying make first person camera in my project. I followed this tutorial http://www.morrowland.com/apron/tutorials/gl/gl_camera_3b.zip
Trying to make a cross protocol, same domain request from https to http. I
Trying to make td elements clickable. Here's my HTML: <td id=A3 class= open-square><a href=/gameplay/A3></a></td>
I'm trying to make a crosstab query (with access tables), But I got lost
I am trying make a request and get response from server. Here is my
I'm trying make Ethos framework on Mac OS Lion. git://git.dronelabs.com/ethos Here result of ./configure:
Trying to make a quick and dirty news system. Have a basic XML file.
Trying to make the infamous checkall checkbox for dynamically created rows from a MySQL
im trying make one replace in string from a array but this dont work
Trying to make a simple jquery drop down here, here's my code so far:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.