Wrox Programmer Forums
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 6th, 2007, 05:03 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default count Q

hello

I am trying to run in for and in the same line to put what the response is. example to what I mean:

<xsl:for-each select = "$counter-db_columns[@class='statistic']">
  <case>
    <xsl:attribute name = "v2">
      <xsl:value-of select="@dbcolumn"/>
    </xsl:attribute>
  </case>
</xsl:for-each>

what I want is to know if there is a function or or some known code, that will put all the out put dbcolumn in v2, v3, v4 and so on, as many dbcolumn that there are.

thanks

 
Old March 6th, 2007, 05:43 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the case v2,v3, v4 should be in the same line, and to not write case for each dbcolumn

 
Old March 6th, 2007, 06:02 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Yes, I'm sure it's achievable, but I don't really understand what your source document looks like. Please provide an example of the source document and the desired output.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 6th, 2007, 06:58 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

source

<etd version="1.0">
 <version major="1" minor="0" />
  <counters>
   <counter tid="101">
    <display color="16" colorRGB="124" sortable="yes" sum-format="byte" avg-format="byte" />
     <data class="statistic" type="float" dbcolumn="BYTES_READ" mandatory="no" func="SUM" collection-id="bytes-read" />
   </counter>
   <counter tid="102">
    <display color="17" colorRGB="125" sortable="yes" sum-format="byte" avg-format="byte" />
    <data class="statistic" type="float" dbcolumn="BYTES_WRITE" mandatory="no" func="SUM" collection-id="bytes-write" />
   </counter>
  </counters>
</etd>

out put should look something like
<case v2="BYTES_READ" v3="BYTES_WRITE">
...
...

now each dbcolumn is different case, and since what filling the case is identical, I though to put all the cases with the same result together

thanks


 
Old March 6th, 2007, 07:41 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Try:

<case>
  <xsl:for-each select="counter">
    <xsl:attribute name="v{position()}">
      <xsl:value-of select="@dbcolumn"/>
    </xsl:attribute>
  </xsl:for-each>
</case>

(But I don't know why your first attribute is v2?)

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 6th, 2007, 08:44 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks

 
Old March 13th, 2007, 04:39 AM
Authorized User
 
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if I want the count to start from a specific number and not from v1 (
for example if I want the first v to be v3 and to start count from there?

 
Old March 13th, 2007, 06:51 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Then replace position() by position()+2.

XPath is an expression language. Any place you can use an expression (like position()), you can use any expression (like position()+2), so long as its value is of the right type.

So this shouldn't really be very difficult to work out for yourself.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: Count = Count + 1 elayaraja.s XSLT 3 July 18th, 2008 03:21 AM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
Need Count Help ~Bean~ SQL Language 11 August 9th, 2005 11:22 PM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM
count() crmpicco MySQL 1 January 28th, 2005 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.