[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Key and document() problem ?

Subject: Re: Key and document() problem ?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 08 Oct 2008 08:33:17 -0400
Re:  Key and document() problem ?
At 2008-10-08 11:42 +0200, Emilise Victor wrote:
> You don't explain why you don't have the for-each loop ...
Because I want to calculate only one value, taking all steps. I used to have
outupts like
<site>
        <step id="1" sum="x" count="x" value="x" />
        <step id="2" sum="x" count="x" value="x" />
</site>

Now I need
<site sum="x" count="x" value="x" />

That's why the loop isn't there anymore.

Sorry, I'm lost ... I cannot tell from your one-line example how multiple step elements are producing a single site element.


I'm not sure myself. My phphinfo gives me 1.1.14 for libxslt and libexslt,
2.6.19 for libxslt compiled against libxml.

Okay, that's XSLT 1.


So, this morning my head was clear and maybe just writing down my problem
helped me understand it better.

Well, it hasn't helped me understand your problem better. Sorry.


Here is my solution :

Seeing what you've written is only helpful when you've given the anticipated inputs and outputs and what your wrong outputs are that need to be repaired.


Couting the steps for wich the test is not over the timeout
<xsl:key name="firstrequest-key" use="concat(../../@id, ../@id)"
match="job/universe/monitor/step/request"/>

<xsl:variable name="count" select="count(monitor/site/test[

document($job)/job/universe/monitor[@id=$monitorid]/@timeout >

sum(request/data[@id=$dataid]/@value)]
<xsl:key name="firstrequest-key" use="concat(../../@id, ../@id)"
match="job/universe/monitor/step/request"/>
                                /request[@id =
(document($job)/job/universe/monitor[@id=$monitorid]/step/request[generate-i
d(.) = generate-id(key('firstrequest-key', concat(../../@id,
../@id))[1])]/@id)])" />

So, this part is ok. Now, I want to know, within the steps I have counted,
how much are over their own timeout, that's where I am now.
<xsl:variable name="sum" select="count(monitor/site/test[

document($job)/job/universe/monitor[@id=$monitorid]/@timeout >

sum(request/data[@id=$dataid]/@value)]

                                /request[
                                @id =
(document($job)/job/universe/monitor[@id=$monitorid]/step[sum($tests/request
[@id = ./request/@id]/data/@value) > @timeout]
                                /request[generate-id(.) =
generate-id(key('firstrequest-key', concat(../../@id, ../@id))[1])]/@id)])"
/>

The problem here is in that part : @id = ./request/@id. This should point to
step/request/@id and I know it doesn't.

You might be needing "@id = current()/request/@id" but that would only work if your current node at the time you declare this variable is a step. Which might be implied by your introductory sentence, but I'm not convinced.


Usually, within my for-each loop, I
could declare variables containing ids, but here I don't know how to get
it...

The current() function is in XSLT, not XPath, and it returns the node that was the current node at the point where the evaluation of the XPath address began.


I hope this helps.

. . . . . . . . . . . . . . Ken

--
Upcoming XSLT/XSL-FO hands-on courses:      Wellington, NZ 2009-01
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video sample lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg
Video course overview:  http://www.youtube.com/watch?v=VTiodiij6gE
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.