Subject: Re: [xsl] same xpath, different results? (more explination) From: "Corey Wilson" <corey@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 23 Jun 2003 11:07:10 -0400 |
Ahhh, ok... so how would i go about setting my situation up... My situation explaination: I want to check a date, and send a param (either rate, or secondaryRate depending on a dateEntered node) and I have a javascript function checking the date. ---start xml--- <client> <id>9001</id> <name>ABC Company</name> <website>R</website> <state>XX</state> <dateEntered>7/23/2002 3:39:00 PM</dateEntered> <dateBillingStart>7/24/2002</dateBillingStart> <monthlyFee>0</monthlyFee> <commissions> <commission> <id>{A1E08DBF-9636-443F-AC29-AFACECFAEC1A}</id> <earnerId>{787C3FCF-6CA2-47D2-9BDE-1B5677DB920C}</earnerId> <product> <revCenter>R</revCenter> <productId>{7123DA51-F1F5-49EE-9A61-0BE57B594048}</productId> <rateType>T</rateType> <rate>0.15</rate> <secondaryRate>0.15</secondaryRate> </product> </commission> <commission> <id>{45F60911-E9A7-40A9-B18A-FC9ABF31961C}</id> <earnerId>{C7CCC2D4-2CBE-4E10-8F38-B0AAF0FF1BC8}</earnerId> <product> <revCenter>R</revCenter> <productId>{819546-F1F5-49EE-9A61-0BE57B594048}</productId> <rateType>T</rateType> <rate>0.15</rate> <secondaryRate>0.05</secondaryRate> </product> </commission> </commissions> <products> <product> <id>{7123DA51-F1F5-49EE-9A61-0BE57B594048}</id> <baseProductId>{EB873465-E7E5-4737-BECE-D5529F0B9710}</baseProductId> <revenueCenter>R</revenueCenter> <bureau>ABC</bureau> <name>Report</name> <price>10</price> <baseCost>1.65</baseCost> <affiliateCost>1.65</affiliateCost> <count>1</count> </product> <product> <id>{819546-F1F5-49EE-9A61-0BE57B594048}</id> <baseProductId>{EB873465-E7E5-4737-BECE-D5529F0B9710}</baseProductId> <revenueCenter>R</revenueCenter> <bureau>ABC</bureau> <name>Report</name> <price>10</price> <baseCost>1.65</baseCost> <affiliateCost>1.65</affiliateCost> <count>450</count> </product> </products> </client> ----end xml----- ./products/product[id=../../commissions/commission[earnerId=$earnerId]/produ ct/productId]/count - gives me (1,450) and I want to be able to pass the paramaters for secondary rate along with it... (0.15,0.05) Sorry for my lack of explination before... Hope this is a little more clear.. Thanks again! -------- start old message ----- <xsl:variable name="totalComm"> <xsl:variable name="whichRate"> <xsl:choose> <xsl:when test="js:overYear(string(../../dateEntered)) = 'false'"> <!-- xsl:value-of select="./commissions/commission[earnerId=$earnerId]/product[productId=../.. /../products/product/id]/rate" / --> <xsl:value-of select="./products/product[id=../../commissions/commission[earnerId=$earnerI d]/product/productId]/count" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="./products/product[id=../../commissions/commission[earnerId=$earnerI d]/product/productId]/count" /> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:call-template name="commTotal"> <xsl:with-param name="cnt" select="./products/product[id=../../commissions/commission[earnerId=$earnerI d]/product/productId]/count" /> <xsl:with-param name="baseCst" select="$whichRate" /> </xsl:call-template> </xsl:variable> In the above code, I am trying to pick a different rate based on a "dateEntred" node. I am not sure why, but the variable $whichRate will always have only 1 element but the paramater cnt will have a variable number of elements... The variable number of elements is what I am going for, but it doesn't seem to work in the first test. The reason I put the same xpath in all of them was just for testing purposes. The reason I am doing this is trying to get either a "rate" or "secondaryRate" depending on the "dateEntered". Thanks for any help! ----end old message --------------- ----- Original Message ----- From: "David Carlisle" <davidc@xxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, June 23, 2003 10:23 Subject: Re: [xsl] same xpath, different results? > > > I am not sure why, but the variable $whichRate will > > always have only 1 element > > No it will have no elements at all. It is a result tree fragment > containg the results of xsl:value-of and xsl:value-of _always_ returns a > string, not an element nor attribute node (so even if you used your > processors node-set extension function to turn the result fragment to a > node set, it still would not contain any element nodes. > > Since you didn't show your input, or your desired output or any > description of what transformation you intend, I can't really suggest > what the code should be. > > > but the paramater cnt will have a variable number > > of elements... > > cnt uses a select attribute so will contain all the nodes selected by > that XPath. > > > David > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star Internet. The > service is powered by MessageLabs. For more information on a proactive > anti-virus service working around the clock, around the globe, visit: > http://www.star.net.uk > ________________________________________________________________________ > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] same xpath, different res, David Carlisle | Thread | Re: [xsl] same xpath, different res, David Carlisle |
[xsl] count in several document, abbouh | Date | Re: [xsl] count in several document, David Carlisle |
Month |