[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: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Mon, 24 Mar 2003 10:54:46 -0600
xsl key combined
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


 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.