Multiple Element Values

Subject: Multiple Element Values
From: Rhonda Fischer <rhonda@xxxxxxxxxxxxxx>
Date: Wed, 19 Apr 2000 12:19:00 +0000
Dear Michael,

Thank you very much for your response to my query, I really
appreciated your assistance. I have since spent quite some time
reading so that I might have a broader understanding of the
possible solutions and hence select the best outcome.

I have some further queries that I was hoping you might be
able to help me with.

My attempt at filling in the Gaps:
------------------------

1:    <xsl:template name="process-items">
2:        <xsl:param name="fragmentQtyPrice"
3:                select="product/ref[@Qty and @Price]"/>
4:            <xsl:if test=fragmentQtyPrice/>
5:                    <xsl:variable name="first"
select="fragmentQtyPrice[1]"/>
6:                    <xsl:variable name="total-of-rest"
7:                               select="<xsl:call-template
name="process-items"/>
8:                                                 <xsl:with-param
name="fragmentQtyPrice
9:
select="fragmentQtyPrice[position()!=1]"/>
10:                   </xsl:variable>
11:                    <xsl:value-of select="$first/Qty * $first/Price +
$total-of-rest"/>
12:    </xsl:template>


Subsequent Questions:
-----------------

Line 2 and 3: Can I create an item list of qty's and price's using
this line of code. I am concerned with the use of 'and' ?

Line 5: I assume this is considering the first occurance of qty and
price
(or rather the top appearing values if liken to a stack-loosing each
first instance of qty and price per loop)

Line 6: Creates a variable total-of-rest which has a recursive nested
xsl:call-template in it's select, (hope I can do this?)

Here I have a question: when passing a value back into a function it's
my understanding the param should be incrementing in value so that
the recursive call will loop through the list of qty and prices. Is
this happening here - how does position()!=1 achieve this???

Line 6: I am not sure if I have correctly setup the param to pass into
the recursive function call?

Line 11 I am not sure at which point I can save the individual
values calculated for qty*price into a variable so that I may finally
display this in a html table. Perhaps I have misunderstood how
to extract the values already put into the result table to finally print

out each cost and a total cost?


Reading Explorations
----------------

I have been excited to read your documentation on SAXON and have
found some bits of code that seem of interest to me in solving my
table of values.

I wondered if I might be able to use of some of this code to:

*  Return a node-set to pass to the function.

     However: is a node-set simply just a match pattern
     on the result tree? As it seems strange that
     xsl would provide the sum function but not a means
     of passing in an arguement of the right type ie. node-set?

                <xsl:variable name="fragment">value</xsl:variable>
                ....
                <xsl:apply-templates
                     select="saxon:node-set($fragment)"
                     mode="postprocess"
                     xmlns:saxon="http://icl.com/saxon"/>


*  Make use of maths functions in java not available in xsl

                 <xsl:value-of select="math:sqrt($arg)"
                    xmlns:math="http://java.sun.com/java.lang.Math"/>

    By the way it seems that sun have moved this library, I
     was not able to find this http resource site?


* I also read about NodeSet Expressions: nodeset-expression1[predicate]
   and ArithmeticExpression(Expression p1, int op, Expression p2)
   and wondered if this might come be part of a successful outcome
   but will give this more thought later.


Again thank you kindly for helping me.

Best Regards
Rhonda


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread