[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: use of xsl:key in cross-referencing

Subject: RE: use of xsl:key in cross-referencing
From: Xiaocun Xu <xiaocunxu@xxxxxxxxx>
Date: Wed, 26 Mar 2003 15:43:20 -0800 (PST)
range.row
Dear Lars:

  Thank you for your reply, your solution is exactly
what I needed.  If creating a key with the same name
using two different groups that key off different
elements, then I need to use apply-templates
separately on the two different groups.  
  Also, you were right when you mention it will miss
QB instead of QC, must've been brain fart, argh!!

Thanks for the help, much appreciated.
Xiaocun

--- Lars Huttar <lars_huttar@xxxxxxx> wrote:
> Dear Xiaocun,
> 
> > To define two keys for the two groups with the
> same
> > name but different "use":
> > <xsl:key name="QuestionnaireKey" match=//row[@row
> &lt;
> > 20]" use="string(cell[@column=2])"/>
> > <xsl:key name="QuestionnaireKey" match=//row[@row
> &gt;
> > 20]" use="string(cell[@column=1])"/>
> >
> > Use Muenchian method to process each just once,
> for
> > the 2nd group:
> > <xsl:apply-templates select="//row[@row &gt; 20
> and
> > @row &lt; 30][count(.|key('QuestionnaireKey',
> > string(cell[@column=1]))[1]) = 1]"/>
> > but this will miss questionnaire QC.
> 
> Huh?  I can see how it will miss questionnaire QB,
> but not QC.
> 
> > I guess to take advantage of the combined key, I
> need
> > to do select on all rows, like:
> > <xsl:apply-templates
> > select="//row[count(.|key('QuestionnaireKey',
> > string(cell[@column=1]))[1]) = 1]"/>
> > Would the above work?
> 
> I don't think so, because it uses @column=1 for all
> rows,
> instead of using @column=2 for the first group and
> @column=1
> for the second group.
> 
> > If so, how can I tell if the
> > row being processed is from group 1
> (Questionnaire) or
> > 2 (Question)?
> 
> Above, you had "@row &gt; 20 and @row &lt; 30".  Do
> you know
> these boundary numbers in advance?  If so, why not
> use them.
> 
> Here's a select expression and template that should
> allow you to
> process each Questionnaire once...
> 
>         <xsl:apply-templates
> select="/range/row[count(.|key('QuestionnaireKey',
>                                     
> string(cell[@column=1 and
>                                        ../@row &gt;
> 20] |
>                                      cell[@column=2
> and
>                                        ../@row &lt;
> 20]))[1]) = 1]" />
> ...
> 
>   <xsl:template match="row">
>     <p>
>       <xsl:choose>
>         <xsl:when test="@row &lt; 20">
>           Processing Questionnaire <xsl:value-of
> select="cell[@column=2]" />
>         </xsl:when>
>         <xsl:otherwise>
>           Processing Questionnaire <xsl:value-of
> select="cell[@column=1]" />
>         </xsl:otherwise>
>       </xsl:choose>
>     </p>
>   </xsl:template>
> 
> I tried this with your test data and it displayed 
> 	Processing Questionnaire QA
> 	Processing Questionnaire QB
> 	Processing Questionnaire QC
> 
> Does this solve your problem?
> 
> Lars
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.