|
Subject: RE: [xsl] use of xsl:key in cross-referencing From: "Lars Huttar" <lars_huttar@xxxxxxx> Date: Mon, 24 Mar 2003 10:54:46 -0600 |
Dear Xiaocun,
> To define two keys for the two groups with the same
> name but different "use":
> <xsl:key name="QuestionnaireKey" match=//row[@row <
> 20]" use="string(cell[@column=2])"/>
> <xsl:key name="QuestionnaireKey" match=//row[@row >
> 20]" use="string(cell[@column=1])"/>
>
> Use Muenchian method to process each just once, for
> the 2nd group:
> <xsl:apply-templates select="//row[@row > 20 and
> @row < 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 > 20 and @row < 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 > 20] |
cell[@column=2 and
../@row < 20]))[1]) = 1]" />
...
<xsl:template match="row">
<p>
<xsl:choose>
<xsl:when test="@row < 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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] use of xsl:key in cross-r, Xiaocun Xu | Thread | RE: [xsl] use of xsl:key in cross-r, Xiaocun Xu |
| Re: [xsl] Breaking up XML(XHTML) in, David Carlisle | Date | [xsl] First Occurance Problem, Deepak Rao |
| Month |