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

creating and accessing element in the same stylesheet

Subject: creating and accessing element in the same stylesheet
From: "Charly" <cohana@xxxxxxxxxxxxxxx>
Date: Mon, 15 Apr 2002 14:58:26 -0700
accessing stylesheet values
Hello Friends
Does anyone have any idea how to create an element in a template and
accessing it with another template within the same stylesheet .
I have a generic template that takes a specific format so I need to reformat
my data before calling the generic template .

Something that would look like :

Stylesheet
----------
<xsl:stylesheet>
   <xsl:template match="/">
      <xsl:element name="root">
         <xsl:for-each select="/report/account">
            <xsl:element name="{name(.)}">
               <xsl:attribute name="name">
                  <xsl:value-of select="@id"/>
               </xsl:attribute>
               <xsl:attribute name="value">
                  <xsl:value-of select="sum(./detail/@value)"/>
               </xsl:attribute>
            </xsl:element>
         </xsl:for-each>
      </xsl:element>
      <xsl:apply-templates />
   </xsl:template>

   <xsl:template match="/root">
      <xsl:for-each select="/root/account">
         <xsl:value-of select="@name"/> <xsl:value-of select="@value"/>,
<br/>
      </xsl:for-each>
      <xsl:apply-templates />
   </xsl:template>
</xsl:stylesheet>




XML Data
--------
<report>
   <account id="X12345" description="Individual">
      <detail symbol="GPRXX" price="1"     value="137"     qty="137" />
      <detail symbol="ODP"   price="21.33" value="9598.50" qty="450" />
      <detail symbol="PFE"   price="39.29" value="3536.10" qty="90"  />
   </account>
   <account id="A256987">
      <detail symbol="ABCAX" price="11.49" value="69717.33" qty="6067.65" />
      <detail symbol="WEINX" price="12.49" value="20855.92" qty="1669.81" />
   </account>
   <account id="A254487">
      <detail symbol="ABCAX" price="11.49" value="69717.33" qty="6067.65" />
      <detail symbol="WEINX" price="12.49" value="20855.92" qty="1669.81" />
   </account>
   <account id="C545251">
      <detail symbol="AKAM" price="11.11" qty="965.38"  value="10725.37"  />
      <detail symbol="SPWX" price="5.20"  qty="492.49"  value="2560.97"   />
      <detail symbol="SUNW" price="13.69" qty="221.37"  value="3030.68"   />
      <detail symbol="AOL"  price="10.92" qty="490.51"  value="5356.43"   />
      <detail symbol="CSCO" price="6.99"  qty="1480.02" value="10345.37"  />
      <detail symbol="YHOO" price="8.56"  qty="1187.62" value="10166.07"  />
   </account>
</report>

Excepted Output
---------------
X12345, 13271.6
A256987, 90573.25
A254487, 90573.25
C545251, 42184.89



Please Help .


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


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.