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

Re: selecting multiple elements

Subject: Re: selecting multiple elements
From: Christopher Hansen <chansen1@xxxxxxxxx>
Date: Mon, 6 Dec 2004 13:47:11 -0500
transactions.xml
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@xxxxxx','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@xxxxxxxxx> 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
> ________________________________________________________________________

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.