| Subject: [xsl] grouping - XSLT 1.0 From: "Lopez, William" <william.lopez@xxxxxxx> Date: Wed, 13 Apr 2005 23:45:07 -0500 | 
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({@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[@Category='Clerical:']">
			<xsl:call-template name="clerical"/>
		</xsl:if>
		<xsl:if test="./Help[@Category='Technical:']">
			<xsl:call-template name="technical"/>
		</xsl:if>
		<xsl:if test="./Help[@Category='Professional:']">
			<xsl:call-template name="professional"/>
		</xsl:if>
		<xsl:if test="./Help[@Category='Supervisor:']">
			<xsl:call-template name="supervisor"/>
		</xsl:if>
		<xsl:if test="./Help[@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_{@ID}" name="helpText_{@ID}"
style="display:none">
	<li>Clerical:</li>
		<ul>
		<xsl:for-each select="./Help[@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
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] xsl:for-each-group, group-sta, Kate Atkins | Thread | [xsl] [SOLVED] RE: [xsl] grouping -, Lopez, William | 
| Re: [xsl] Transforming XML Blockquo, James Fuller | Date | [xsl] [SOLVED] RE: [xsl] grouping -, Lopez, William | 
| Month |