xsl-list
[Top] [All Lists]

Re: Grouping

2005-12-07 02:34:16





Hi Ragulf,
           I  take back my previous post as I don't see where I am wrong.
The muenchian grouping is not required for the answers and only for the
questions that too only if the OP is prticular about it.

Otherwise, my code should work fine.

cheers,
prakash

















                                                                                
                                                       
                      Ragulf Pickaxe                                            
                                                       
                      <ragulf.pickaxe@         To:      
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com                                
                
                      gmail.com>               cc:      (bcc: 
omprakash.v/Polaris)                                                     
                                               Subject: Re: [xsl] Grouping      
                                                       
                      12/07/2005 02:55                                          
                                                       
                      PM                                                        
                                                       
                      Please respond                                            
                                                       
                      to xsl-list                                               
                                                       
                                                                                
                                                       
                                                                                
                                                       




Hi prakash,

 <xsl:output method="xml"/>

<xsl:key name="rec" match="row" use="question_id"/>

<xsl:template match="/recordset">

<xsl:for-each select="row">
<xsl:if test="generate-id(.) = generate-id(key('rec', question_id))">
<xsl:text>
</xsl:text>
Answers for question <xsl:value-of select="question_id"/>
</xsl:if>
<xsl:text>
</xsl:text>

<xsl:value-of select="key('rec', question_id)/answer"/>
<xsl:text>
</xsl:text>

</xsl:for-each>

 </xsl:template>

Will you not have a problem here, if question_id are not ordered?
As I read it, you go through all row elements. You check if the value
of question_id is the first of its kind, and if it is, you write the
Answers to question...
Then you proceed to write the value of the answer element.
As I see it, <xsl:value-of select="key('rec', question_id)/answer"/>
is the same as <xsl:value-of select="answer"/>, and as you have not
made sure of the value of question_id in your for-each, then this can
be wrong.

If I have not understood this correctly, please correct me.

A key approach, I would use (modifying your template):

<xsl:for-each select="row[generate-id(.) = generate-id(key('rec',
question_id))]">
Answers for question <xsl:value-of select="question_id"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="key('rec', question_id)/answer">
<xsl:value-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

This one will work no matter the order of question_id's.

Regards,
Ragulf Pickaxe :-)

--~------------------------------------------------------------------
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>
--~--





This e-Mail may contain proprietary and confidential information and is sent 
for the intended recipient(s) only. 
If by an addressing or transmission error this mail has been misdirected to 
you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction, 
dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its 
attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>