[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] use of xsl:key in cross-referencing
Subject: Re: [xsl] use of xsl:key in cross-referencing From: Xiaocun Xu <xiaocunxu@xxxxxxxxx> Date: Thu, 20 Mar 2003 15:36:33 -0800 (PST) |
Hi, Wendell: Thanks for the idea of define two keys for the two groups with the same name but different "use" value, but I was unable to find anything in regard to it at Jenni's website, xsl-list archive (using keywords "two key;same name;") or google web/group. I did some thinking myself and still don't see how that works. Following is an example, having rows 10-19 being the first group (Questionnaire) and 20-29 being the second group (Question): <range> <row row="16"> <cell column="1">Questionnaire A</cell> <cell column="2">QA</cell> <cell column="3">Questionnaire A, two questions</cell> </row> <row row="17"> <cell column="1">Questionnaire B</cell> <cell column="2">QB</cell> <cell column="3">Questionnaire B, empty with no questions</cell> </row> <row row="27"> <cell column="1">QA</cell> <cell column="2">Questionnaire A, Question 1<cell> </row> <row row="28"> <cell column="1">QA</cell> <cell column="2">Questionnaire A, Question 2</cell> </row> <row row="29"> <cell column="1">QC</cell> <cell column="2">Questionnaire C, Question 1</cell> </row> </range> In this case, questionnaire QA has two questions, QB is only referred in the 1st group and QC is only referred in the 2nd group. What I need is to be able to process each of QA/QB/QC. 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. 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? If so, how can I tell if the row being processed is from group 1 (Questionnaire) or 2 (Question)? Thanks, Xiaocun --- Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> wrote: > Xiaocun, > > At 07:39 PM 3/19/2003, you wrote: > > > > When I process the 1st group of rows > > > >(questionnaires), I call key() function by > passing > > > in > > > >the value in the 2nd cell. > > > > > > Ignore the first group of rows and just iterate > over > > > the questions, using > > > your key to group them. > > > >That was the first came to my mind as well, but the > >problem is that a questionnaire defined in 1st > group > >may not be used in the 2nd group, those will be > >omitted. I am looking for a way to combine the two > >groups so that every questionnaire is processed as > >long as it is used in 1st (questionnaires) or 2nd > >group (questions). Order to me is not important. > > In that case, you can iterate over and de-duplicate > from both groups. > > In fact, you can define two keys for the two groups > with the same name, > only different "use" values, which could help in > this. > > I'd be more explicit about this, except (a) it's > much harder to write up > without some sample code to chew on (please post > again with your source and > problem statement?), and (b) I'm in a time crunch > today. > > But I learned this trick from Jeni: I think if you > look in the FAQ and on > Jeni's site (http://www.jenitennison.com), where > grouping is covered in > some detail, you could find something. > > Cheers, > Wendell > > > ====================================================================== > Wendell Piez > mailto:wapiez@xxxxxxxxxxxxxxxx > Mulberry Technologies, Inc. > http://www.mulberrytech.com > 17 West Jefferson Street Direct > Phone: 301/315-9635 > Suite 207 > Phone: 301/315-9631 > Rockville, MD 20850 > Fax: 301/315-8285 > ---------------------------------------------------------------------- > Mulberry Technologies: A Consultancy Specializing > in SGML and XML > ====================================================================== > > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > __________________________________________________ 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] use of xsl:key in cross-r, Wendell Piez | Thread | Re: [xsl] use of xsl:key in cross-r, Wendell Piez |
Re: [xsl] where does one stick the , Chris Loschen | Date | Re: [xsl] where does one stick the , Mike Brown |
Month |
Keywords