Search

ok i must be missing something here, here is some sudo code and the actual code i have. I want to add all the “totalcash” variables from the template match=sold-to, but cant figure out how.

template A counts the entries in “books” and figures out how much each “book shelf” costs this apply-template B /template

template B displays all books in “book shelf” /template

how do i add the cost of each “book shelf” to figure out how much the store is worth.

http://pastie.org/1340379

(code wasnt pasting in properly)

@jeffleeder - would you mind posting your XML?

 <carrier-billings>
    <section id="22" handle="leads">Leads</section>
    <sold-to link-id="764" link-handle="###">
        <entry id="1512">
            <name handle="##">##</name>
            <email handle="##">##</email>
            <lastname handle="##">##</lastname>
            <province handle="##">##</province>
            <postal handle="###">##</postal>
            <phone handle="##">##</phone>
            <date-day handle="##">##</date-day>
            <date-month handle="##">##</date-month>
            <date-year handle="##">##</date-year>
            <free>No</free>
            <notes />
        </entry>

<carriers>
  <entry id="352" leads="235" other-items="1"  invoices="0" postal-codes="93">
        <companyname handle="##">##</companyname>
        <last-invoiced time="08:06" weekday="3">2010-12-01</last-invoiced>
        <carrieremail handle="##">##</carrieremail>
        <id hash="##">##</id>
        <address handle="##">##</address>
        <province handle="##">##</province>
        <city handle="##">## </city>
        <amount1 handle="##">##</amount1>
        <amount2 handle="##">##</amount2>
        <agedivider handle="##">##</agedivider>

Ok maybe this is easier I have a template spitting out a series of number how do I add them together?

Are you trying to add amount1 and amount2 together?

If so, try this, <xsl:value-of select="amount1 + amount2"/>

If it’s a different amount of numbers each time you run it, using + probably isn’t going to work. I’d suggest using a recurring template on the nodes, that calls itself populating a parameter with the result of the last recursion. The first call to the template would use the parameter as 0.

PS I would write it out for you, but I have moved and can’t find the laptop :(

Yea i have a recursion template i just dont know how to output the param for each iteration in a way I can use. The template just spits out numbers

If you use position() = last() in a choose statement to do something different for the last recursion, you can have the template output the final number, for all the other iterations, just add the params together without any output.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details