Subject: RE: [xsl] Retaining value of a Global variable From: "Michael Kay" <mhk@xxxxxxxxx> Date: Mon, 19 Jul 2004 20:17:50 +0100 |
The logic for this is simply to translate your English-language description into code: <xsl:variable name="articles" select="article[class='WebCasts']"/> <xsl:if test="$articles"> <title>WebCasts</title> <xsl:apply-templates select="$articles"/> </xsl:if> Here test="$articles" tests to see whether the $articles node-set is non-empty. You could write it as test="count($articles) != 0", but the coding idiom used above soon becomes familiar. Michael Kay > -----Original Message----- > From: Vivek Shinde [mailto:Vivek.Shinde@xxxxxxx] > Sent: 19 July 2004 19:02 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] Retaining value of a Global variable > > Hi, > I'll post it soon. I am trying to find simpler solution. > Michael had suggested position() but since I may have the > article(s) at any position, that would not work. I am trying > with xsl:key. > > My main problem is: > I have an XML that contains multiple articles for a > newsletter. There could or could not be some articles with > article-classification as 'Webcasts'. If I find even a single > article with classification of 'Webcast', then I want to > print a title 'Webcasts' and then list all the articles. I > have done the code for listing the articles. The problem I am > having is identifying if there's even one article of that > classification and then print 'Webcast' title only once. > That's why I was looking to set the global variable and then > increment it once I hit the first webcast article and then go > for listing the articles of that type. But it seems that's > not possible. Therefore I am trying xsl:key. Any other input > on doing it simpler way? > > The XML sample: > <article> > <class>News</class> > <teaser>AAAAAAAAAA</teaser> > </article> > <article> > <class>Webcast</class> > <teaser>BBBBBBBBBB </teaser> > </article> > <article> > <class>News</class> > <teaser>CCCCCCCCCCC </teaser> > </article> > <article> > <class>Webcast</class> > <teaser>DDDDDDDD </teaser> > </article> > > Thanks > Vivek > > -----Original Message----- > From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx] > Sent: Monday, July 19, 2004 11:05 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Re: [xsl] Retaining value of a Global variable > > > I'm going to leave this one aside for a bit. Until we hear again from > Vivek, it's not clear to me that this is -- quite -- a > standard grouping > problem, due to the requirement to group according to string > containment, > not just string equality. > > It'd be much easier if we could see a representative example > of the input. > Vivek, could you post a bit of it, along with a restatement > of what kind of > output you want for your input? That way it's all in one > email -- less to > guess, less confusing to track. > > On the other hand, maybe our haphazard comments and hints > have been enough > to help Vivek find the solution on his own. > > Cheers, > Wendell > > At 10:32 AM 7/19/2004, M.David wrote: > >After being "woken up" to a fresh breath of "oh my goodness did I > >really > >swing and miss before the ball even crossed the plate".... > > > > ====================================================================== > 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 > ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Retaining value of a Glob, Vivek Shinde | Thread | Re: [xsl] Retaining value of a Glob, M. David Peterson |
RE: [xsl] Retaining value of a Glob, Vivek Shinde | Date | [xsl] Need: XSL FO Schema/ .XSD/ Va, SANWAL, ABHISHEK (HP |
Month |