I got it to work but it's still ugly. I'm still interested in doing it
correctly (or a more eloquent solution :-).
Thanks
-----Original Message-----
From: Lopez, William
Sent: Wednesday, April 13, 2005 11:45 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] grouping - XSLT 1.0
List:
[Will] I've tried the Muenchian Method with no success (my lack of
understanding).
I have the following xml that will be transformed in an unordered list in
html. Each category is processed differently - Cat 2 is what I'm trying to
nail:
<root>
<Category ID="1" Name="Relate">
...
</Category>
<Category ID="2" Name="Response">
<Question ID="34" Text="Customer Focus" >
<Help ID="203" Category="Clerical:" Text="c1"/>
<Help ID="204" Category="Clerical:" Text="c2"/>
<Help ID="206" Category="Technical:" Text="t1"/>
<Help ID="207" Category="Technical:" Text="t2"/>
<Help ID="209" Category="Professional:" Text="p1"/>
<Help ID="210" Category="Professional:" Text="p2"/>
<Help ID="212" Category="Supervisor:" Text="s1"/>
<Help ID="213" Category="Supervisor:" Text="s2"/>
</Question>
<Question ID="35" Text="Integrity and Trust"">
<Help ID="203" Category="Clerical:" Text="c1"/>
<Help ID="204" Category="Clerical:" Text="c2"/>
<Help ID="206" Category="Technical:" Text="t1"/>
<Help ID="207" Category="Technical:" Text="t2"/>
<Help ID="209" Category="Professional:" Text="p1"/>
<Help ID="210" Category="Professional:" Text="p2"/>
<Help ID="212" Category="Supervisor:" Text="s1"/>
<Help ID="213" Category="Supervisor:" Text="s2"/>
</Question>
</Category>
</root>
The output should be similar to this the '>>' represents an icon which
toggles the help elements visibility (they're in a div):
Customer Focus
O Clerical
[] c1
[] c2
0 Technical
[] t1
[] t2
...
Integrity and Trust
O Clerical
[] c1
[] c2
0 Technical
[] t1
[] t2
...
How do I get these grouped so that each div represents the appropriate
question. Currently, my xslt does not - it uses the same <Question> id for
all questions which means the div's ids are not unique. I could not get the
Muenchian Method to work so I tried a 'simple' solution.
The xsl:
...
<xsl:template name="questionhelp">
<xsl:param name="title"/>
<!-- Write the help image -->
<input type='image' src='/PMP/common/images/ico_collapsed.gif'
onclick='ShowHelpText({(_at_)ID},this);' width='16' height='16' border='2' />
<!-- Write the text -->
<xsl:text> </xsl:text><xsl:value-of select="$title"/>
<!-- **************************************************** -->
<!-- I tried this but didn't yield the result I wanted
<xsl:if test="./Help[(_at_)Category='Clerical:']">
<xsl:call-template name="clerical"/>
</xsl:if>
<xsl:if test="./Help[(_at_)Category='Technical:']">
<xsl:call-template name="technical"/>
</xsl:if>
<xsl:if test="./Help[(_at_)Category='Professional:']">
<xsl:call-template name="professional"/>
</xsl:if>
<xsl:if test="./Help[(_at_)Category='Supervisor:']">
<xsl:call-template name="supervisor"/>
</xsl:if>
<xsl:if test="./Help[(_at_)Category='Leader:']">
<xsl:call-template name="leader"/>
</xsl:if>
-->
<!-- **************************************************** -->
<!--
so I tried using this and *hoped* a match would do the
trick, it did not
-->
<xsl:apply-templates />
</xsl:template>
<xsl:template match="Help" name="clerical2">
<!-- Write the help -->
<div class="helpText" id="helpText_{(_at_)ID}"
name="helpText_{(_at_)ID}"
style="display:none">
<li>Clerical:</li>
<ul>
<xsl:for-each select="./Help[(_at_)Category='Clerical:']">
<li>
<xsl:value-of select="./@Text"/>
</li>
</xsl:for-each>
</ul>
</div>
</xsl:template>
This blows up. I can not figure out how to accomplish this without hard
coding the category type. I would like to find a 'generic' way to handle it.
Thanks,
-Will
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--