xsl-list
[Top] [All Lists]

Re: selecting multiple elements

2004-12-06 11:47:11
David, 
In my source, you will notice I have 2 xml files.  Transactions.xml
(as noted previously) and itemsets.xml which looks something like what
is shown directly below.
Essentially, im trying to match the items from each XML document
together, and send out coupons for these items in one email.  However,
I cant get more than one item into each email.  It sends one email per
item right now. Confused on how to accomplish this.

<frequent_item_sets>
  <set id="1" coupon="50 cents">
    <item>Milk</item> 
    <item>Butter</item>
    <item>Eggs</item>
  </set>

  <set id="2" coupon="75 cents">
     <item>Hot Pockets</item>
     <item>Mini Pizza Bagels</item>
     <item>SuperPretzel</item>
     <item>Popcorn Shrimps</item>
</set>
....

---------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:myJava="http://xml.apache.org/xslt/java";
exclude-result-prefixes="myJava" version="1.0">

        <xsl:param name="itemsets" select="document('itemsets.xml')"/>
        <xsl:param name="transactions" select="document('transactions.xml')"/>

        <xsl:output method="html"/>
        <xsl:template match="/">

        <xsl:for-each select="$transactions//transaction/items/item" >

          <xsl:variable name="thePerson" select="../../customer/name"/>
          <xsl:variable name="email" select="../../customer/email"/>
          <xsl:variable name="theItem" select="." />

           <xsl:if test="$theItem= $itemsets//item">
               <xsl:for-each select="$itemsets/frequent_item_sets//set" >
                <xsl:if test ="$theItem=item">
                       <xsl:variable name="msg"
select='concat($theItem,$thePerson)'/>
                       <xsl:value-of
select="myJava:myMail.send($email,'test(_at_)hi(_dot_)com','Coupon!!!', $msg)" 
/>

               </p>

              </xsl:if>
            </xsl:for-each>
         </xsl:if>
       </xsl:for-each>








On Mon, 6 Dec 2004 18:10:27 GMT, David Carlisle 
<davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:

<xsl:for-each select="$transactions/transactions//transaction/items"
                                                ^^
                   it's very inefficient to have // here but without
                   seeing your source can't suggest anything else.
                   perhaps just / ?

 <xsl:variable name="thePerson" select="../customer/name"/>
   <xsl:variable name="email" select="../customer/email"/>
   <xsl:variable name="msg" select="item"/>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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



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