Subject: Re: [xsl] Lookup Table? From: Josh Canfield <joshcanfield@xxxxxxxxx> Date: Tue, 17 Aug 2004 14:41:23 -0700 |
Yes, it looks like you'll need to enumerate the valid account values, either in a lookup table, or if your values are limited you could use something like: <xsl:variable name="open-account-ids" select="':01:02:03:04:05:06:07:08:09:B:AC:'"/> <xsl:value-of select="count(//MOP[contains($open-account-ids, concat(':', ., ':'))])"/> If you think you might get a : in your MOP value, then pick a delimiter that won't... As for your sum problem, assuming you can just skip the non-number values, try this: <xsl:value-of select="sum($lstAccount[Account_Name=$grpRecord2]/Payment[number(.) > 0])" /> Josh On Tue, 17 Aug 2004 19:37:12 +0000, john lee <excel_man@xxxxxxxxxxx> wrote: > Thank you all for the previous answers. > I just got extra documentation where there are some cases where the code > indicator for opened account could be a char ('B', 'AC'). In this case, > should I use a lookup table ? > > Are there any other good lookup table sample I can refer to ? > > My other question is: > If you use the number function, and if there are a couple of result that > comes back 'UNKNOWN' instead of a number, it will cast a NaN right ? and if > you do sum($total), it will give you NaN again. > How do you avoid this ? > > This is my code to get the total: > <xsl:key name="keyAccount" match="Trades/Record" use="Account_Type" /> > > <xsl:for-each select="$lstAccount[generate-id(.) = > generate-id(key('keyName', Account_Name))]"> > <xsl:variable name="grpRecord2" select="Account_Name"/> > <tr> > <td colspan="4"> > <xsl:value-of > select="$lstAccount[Account_Name=$grpRecord2]/Account_Name" /> > </td> > <td colspan="1" class="RightJustified"> > <!-- Show the total High for the current Employee --> > <xsl:value-of > select="sum($lstAccount[Account_Name=$grpRecord2]/Payment)" /> > </td> > </tr> > </xsl:for-each> > > Any help would be appreciated, > > Cezar > > >From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> > >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >Subject: Re: [xsl] Lookup Table? > >Date: Tue, 17 Aug 2004 12:30:30 -0400 > >MIME-Version: 1.0 > >X-Sender: wapiez@xxxxxxxxxxxxx > >Received: from h01.biglist.com ([209.123.46.101]) by mc1-f24.hotmail.com > >with Microsoft SMTPSVC(5.0.2195.6824); Tue, 17 Aug 2004 10:28:06 -0700 > >Received: (qmail 67309 invoked by uid 2149); 17 Aug 2004 17:27:13 -0000 > >Received: (qmail 67235 invoked from network); 17 Aug 2004 17:27:12 -0000 > >X-Message-Info: JGTYoYF78jEcb408jTll/5zNZ3AdAsyH > >Mailing-List: contact xsl-list-help@xxxxxxxxxxxxxxxxxxxxxx > >Precedence: bulk > >X-BL-Legal-Notice: <http://www.BIGLIST.com/legal/> > >X-Complaints-To: <mailto:abuse@xxxxxxxxxxx> > >List-Post: <mailto:xsl-list@xxxxxxxxxxxxxxxxxxxxxx> > >List-Help: <mailto:xsl-list-help@xxxxxxxxxxxxxxxxxxxxxx> > >List-Unsubscribe: > ><mailto:xsl-list-unsubscribe-excel_man=hotmail.com@xxxxxxxxxxxxxxxxxxxxxx> > >List-Subscribe: <mailto:xsl-list-subscribe@xxxxxxxxxxxxxxxxxxxxxx> > >Delivered-To: mailing list xsl-list@xxxxxxxxxxxxxxxxxxxxxx > >Message-Id: <6.0.0.22.0.20040817122848.02da7e30@xxxxxxxxxxxxx> > >X-Mailer: QUALCOMM Windows Eudora Version 6.0.0.22 > >In-Reply-To: <f2a58075040816190764d3a0cf@xxxxxxxxxxxxxx> > >References: <BAY9-F58huAOyvuga7k0003059a@xxxxxxxxxxx> > ><f2a58075040816190764d3a0cf@xxxxxxxxxxxxxx> > >Return-Path: > >xsl-list-return-4757-excel_man=hotmail.com@xxxxxxxxxxxxxxxxxxxxxx > >X-OriginalArrivalTime: 17 Aug 2004 17:28:07.0842 (UTC) > >FILETIME=[8F9DE820:01C4847F] > > > > > >Cezar, > > > >At 10:07 PM 8/16/2004, Josh wrote: > >>How about something like this? > >><xsl:value-of select="count(//MOP[number(.)>0])"/> > > > >I like this. It leverages your rule that open accounts are numbered, > >whereas non-numbered accounts will cast to NaN when you use the number() > >function. Hence, no lookup table is required. > > > >Cheers, > >Wendell > > > >> > This is the situation: I need to get the number of currently open > >>account > >> > (which is indicated by MOP element), If MOP value is a number, not a > >> > 2-char-code, then the current account is opened, otherwise it's close. > >>The > >> > MOP number could be 01 - 09. This is the xml: > > > > > > > >====================================================================== > >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 > >====================================================================== > > > > _________________________________________________________________ > MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. > http://join.msn.com/?page=features/virus
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Lookup Table?, john lee | Thread | [xsl] XSLT: question re testing for, Ralph Holz |
Re: [xsl] Traverse XML Source, cking | Date | Re: [xsl] What to use instead of a , Josh Canfield |
Month |