xsl-list
[Top] [All Lists]

Re: [xsl] Key and document() problem ?

2008-10-08 08:33:50
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[(_at_)id=$monitorid]/@timeout >

sum(request/data[(_at_)id=$dataid]/@value)]
<xsl:key name="firstrequest-key" use="concat(../../@id, ../@id)"
match="job/universe/monitor/step/request"/>
                                /request[(_at_)id =
(document($job)/job/universe/monitor[(_at_)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[(_at_)id=$monitorid]/@timeout >

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

                                /request[
                                @id =
(document($job)/job/universe/monitor[(_at_)id=$monitorid]/step[sum($tests/request
[(_at_)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(_at_)CraneSoftwrights(_dot_)com
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>