 |
| 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
|
|
|
|

March 6th, 2007, 05:03 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 6th, 2007, 05:43 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
the case v2,v3, v4 should be in the same line, and to not write case for each dbcolumn
|
|

March 6th, 2007, 06:02 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

March 6th, 2007, 06:58 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 6th, 2007, 07:41 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

March 6th, 2007, 08:44 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks
|
|

March 13th, 2007, 04:39 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|
|

March 13th, 2007, 06:51 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|
 |