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 8048301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:23:24+00:00 2026-06-05T06:23:24+00:00

I have been reading up on the Muenchian Method, but am just not understanding

  • 0

I have been reading up on the Muenchian Method, but am just not understanding the grouping to generate the html formatted how I need it.

Here is the source xml.

<?xml version="1.0" encoding="UTF-8"?>
<env>
<paramCount>4</paramCount>
<param parameter="id" value="1371"/>
<param parameter="xform" value="none"/>
<param parameter="user" value="Administrator"/>
<param parameter="time-stamp" value="Jun 5, 2012 2:29:45 PM"/>
<sql name="Matrix Demo" qid="1371">
    <row num="1">
        <col meta="MATRIX.X_TITLE" grp="0" label="X" type="12" name="X">1-Sample Topic</col>
        <col meta="MATRIX.X_ID" grp="0" label="X_ID" type="2" name="X_ID">3838</col>
        <col meta="MATRIX.Y_TITLE" grp="0" label="Y" type="12" name="Y">DC</col>
        <col meta="MATRIX.Y_ID" grp="0" label="Y_ID" type="2" name="Y_ID">4909</col>
        <col meta="MATRIX.PRIORITY" grp="0" label="Priority" type="2" name="Priority">1740</col>
    </row>
    <row num="2">
        <col meta="MATRIX.X_TITLE" grp="0" label="X" type="12" name="X">1-Sample Topic</col>
        <col meta="MATRIX.X_ID" grp="0" label="X_ID" type="2" name="X_ID">3838</col>
        <col meta="MATRIX.Y_TITLE" grp="0" label="Y" type="12" name="Y">Maryland</col>
        <col meta="MATRIX.Y_ID" grp="0" label="Y_ID" type="2" name="Y_ID">4910</col>
        <col meta="MATRIX.PRIORITY" grp="0" label="Priority" type="2" name="Priority">1740</col>
    </row>
    <row num="3">
        <col meta="MATRIX.X_TITLE" grp="0" label="X" type="12" name="X">1-Sample Topic</col>
        <col meta="MATRIX.X_ID" grp="0" label="X_ID" type="2" name="X_ID">3838</col>
        <col meta="MATRIX.Y_TITLE" grp="0" label="Y" type="12" name="Y">Virginia</col>
        <col meta="MATRIX.Y_ID" grp="0" label="Y_ID" type="2" name="Y_ID">4908</col>
        <col meta="MATRIX.PRIORITY" grp="0" label="Priority" type="2" name="Priority">1740</col>
    </row>
    <row num="4">
        <col meta="MATRIX.X_TITLE" grp="0" label="X" type="12" name="X">2-Sample Topic</col>
        <col meta="MATRIX.X_ID" grp="0" label="X_ID" type="2" name="X_ID">4901</col>
        <col meta="MATRIX.Y_TITLE" grp="0" label="Y" type="12" name="Y">DC</col>
        <col meta="MATRIX.Y_ID" grp="0" label="Y_ID" type="2" name="Y_ID">4909</col>
        <col meta="MATRIX.PRIORITY" grp="0" label="Priority" type="2" name="Priority">1741</col>
    </row>
    <row num="5">
        <col meta="MATRIX.X_TITLE" grp="0" label="X" type="12" name="X">2-Sample Topic</col>
        <col meta="MATRIX.X_ID" grp="0" label="X_ID" type="2" name="X_ID">4901</col>
        <col meta="MATRIX.Y_TITLE" grp="0" label="Y" type="12" name="Y">Maryland</col>
        <col meta="MATRIX.Y_ID" grp="0" label="Y_ID" type="2" name="Y_ID">4910</col>
        <col meta="MATRIX.PRIORITY" grp="0" label="Priority" type="2" name="Priority">1741</col>
    </row>
    <row num="6">
        <col meta="MATRIX.X_TITLE" grp="0" label="X" type="12" name="X">2-Sample Topic</col>
        <col meta="MATRIX.X_ID" grp="0" label="X_ID" type="2" name="X_ID">4901</col>
        <col meta="MATRIX.Y_TITLE" grp="0" label="Y" type="12" name="Y">Virginia</col>
        <col meta="MATRIX.Y_ID" grp="0" label="Y_ID" type="2" name="Y_ID">4908</col>
        <col meta="MATRIX.PRIORITY" grp="0" label="Priority" type="2" name="Priority">1741</col>
    </row>
    ...
</sql>
</env>

This is what I am trying to achieve.

<html>
<body>
<table border="1" width="500px">
<thead>
    <tr>
        <th>&#160;</th>
        <th>1-Sample Topic</th>
        <th>2-Sample Topic</th>
        <th>3-Sample Topic</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>DC</td>
        <td>1740</td>
        <td>1741</td>
        <td>1742</td>
    </tr>
    <tr>
        <td>Maryland</td>
        <td>1740</td>
        <td>1741</td>
        <td>1742</td>
    </tr>
    <tr>
        <td>Virginia</td>
        <td>1740</td>
        <td>1741</td>
        <td>1742</td>
    </tr>
</tbody>
</table>
</body>
</html>

I haven’t really come close to getting the output as I need it. I did get the example from http://www.jenitennison.com/xslt/grouping/muenchian.html but did not get any further than that.

I can control what data comes out in the col sections, but the overall tree I cannot change. Any help will be greatly appreciated.

  • 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-05T06:23:25+00:00Added an answer on June 5, 2026 at 6:23 am

    You don’t say which of the <col> elements are the most reliable ones to group on, but I presume the ones with name="X_ID" and name="Y_ID" are appropriate.

    The purpose of the Muenchian method is to quickly locate all elements with an identical characteristic. So in this case we need to group the rows by the value of their X_ID columns to find the text to go in the <th> elements of the first row, and separately by the value of their Y_ID columns to determine which rows to display in the <td> elements of subsequent lines.

    This stylesheet does the grouping as you specified. The output when it is applied to the data you have given is shown beneath it.

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0">
    
      <xsl:output method="html" indent="yes"/>
      <xsl:strip-space elements="*"/>
    
      <xsl:key name="rows_by_x_id" match="row" use="col[@name='X_ID']" />
      <xsl:key name="rows_by_y_id" match="row" use="col[@name='Y_ID']" />
    
      <xsl:template match="/env/sql">
    
        <html>
          <body>
    
            <table border="1" width="500px">
    
              <tr>
                <th>&#160;</th>
                <xsl:for-each select="row[generate-id() = generate-id(key('rows_by_x_id', col[@name='X_ID']))]">
                  <th>
                    <xsl:value-of select="col[@name='X']"/>
                  </th>
                </xsl:for-each>
              </tr>
    
              <xsl:for-each select="row[generate-id() = generate-id(key('rows_by_y_id', col[@name='Y_ID']))]">
                <tr>
                  <td>
                    <xsl:value-of select="col[@name='Y']"/>
                  </td>
                  <xsl:for-each select="key('rows_by_y_id', current()/col[@name='Y_ID'])">
                    <td>
                      <xsl:value-of select="col[@name='Priority']"/>
                    </td>
                  </xsl:for-each>
                </tr>
              </xsl:for-each>
    
            </table>
    
          </body>
        </html>
    
      </xsl:template>
    
    </xsl:stylesheet>
    

    output

    4<html>
       <body>
          <table border="1" width="500px">
             <tr>
                <th>&nbsp;</th>
                <th>1-Sample Topic</th>
                <th>2-Sample Topic</th>
             </tr>
             <tr>
                <td>DC</td>
                <td>1740</td>
                <td>1741</td>
             </tr>
             <tr>
                <td>Maryland</td>
                <td>1740</td>
                <td>1741</td>
             </tr>
             <tr>
                <td>Virginia</td>
                <td>1740</td>
                <td>1741</td>
             </tr>
          </table>
       </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading so many topics here about this, but I could not
I have been reading the Phing documentation and it makes sense, but I'm not
I have been reading a lot about both PEP-333 and PEP-3333 . But I
I have been reading about branch prediction but the only implementation I find are
I have been reading this blog post and this stack overflow post but I
I have been reading over a lot of questions, but cant seem to find
I have been reading the doc and searching but cannot seem to find a
I have been reading about UnitOfWork pattern for last two days but didn't understand
I have been reading about how read.table is not efficient for large data files.
I have been reading a lot about openFrameworks and Processing, But still can't make

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.