7 Replies - 869 Views - Last Post: 28 November 2012 - 12:36 PM Rate Topic: -----

#1 hugoriffic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 185
  • Joined: 16-September 09

XML and XSLT Table and Description Help

Posted 28 November 2012 - 10:10 AM

I'm working on a project in XML and XSLT and have done quite a bit of it. All that is left is to put a table below the name of each of companies names (on the left hand side) and then a description of the company on the right hand side of the corresponding table.

First off, I cannot figure out how to get each table to go beneath the proper company name. In fact all I have is one table that sits at the bottom of the page. I believe there are 14 companies and each one needs a table beneath it. How do you accomplish adding a table to each company?

Secondly, I need to fill the second column of the table in each row with some information that directly relates to that company. I understand how to work with data to fill a table but this information is not data. For example the first row and column within the table is "Category". For the second column in that row I need the right type of category to show up, as in "Industrial", but the word "Industrial" is not data - it is set up as follows: <category>Industrial</category>.

Lastly, I need each companies description to sit below the company name. All I get is one big paragraph, with all of the companies descriptions, that sits below all of the company names.

Here is a link to my website: http://itweb.fvtc.ed...ct16/stock2.xml

Here is my code:

XML
<?xml version="1.0" encoding="UTF-8" ?>

<?xml-stylesheet type="text/xsl" href="stock2.xsl"?>

<portfolio>

   <stock>
      <sName symbol="AA">Aluminum Company of America</sName>
      <description>Alcoa Inc. is a producer of primary aluminum, fabricated aluminum, and 
                   alumina, and is active in all major aspects of the industry, including 
                   technology, mining, refining, smelting, fabricating, and recycling. 
                   Alcoa serves customers worldwide in the packaging, consumer, automotive, 
                   aerospace and other transportation, building and construction, industrial 
                   products and distribution markets. Related businesses include packaging 
                   machinery, precision castings, vinyl siding, plastic bottles and closures, 
                   fiber-optic cables, and electrical distribution systems for cars and 
                   trucks. Alcoa's operations consist of five worldwide segments: Alumina 
                   and Chemicals, Primary Metals, Flat-Rolled Products, Engineered Products, 
                   and Packaging and Consumer Goods.
      </description>
      <category>Industrials</category>
      <link>http://www.alcoa.com</link>
      <year_high>42.00</year_high>
      <year_low>27.36</year_low>
      <pe_ratio>39.40</pe_ratio>
      <earnings>0.73</earnings>
      <yield>2.09</yield>
      <today open="29.60" high="29.94" low="28.59" current="29.20" vol="2.94" />
   </stock>

   <stock>
      <sName symbol="UCL">Unocal Corporation</sName>
      <description>Unocal Corporation operates as the parent of Union Oil Company of 
                   California. Virtually all operations are conducted by Union Oil and 
                   its subsidiaries. Unocal is an independent oil and gas exploration 
                   and production company, with principal operations in North America 
                   and Asia. Unocal is also a producer of geothermal energy and a provider 
                   of electrical power in Asia. Other activities include ownership in 
                   proprietary and common carrier pipelines, natural gas storage facilities 
                   and the marketing and trading of hydrocarbon commodities.
      </description>
      <category>Industrials</category>
      <link>http://www.unocal.com</link>
      <year_high>39.70</year_high>
      <year_low>29.51</year_low>
      <pe_ratio>24.57</pe_ratio>
      <earnings>1.34</earnings>
      <yield>2.43</yield>
      <today open="33.35" high="34.00" low="32.66" current="33.80" vol="1.01" />
   </stock>

   <stock>
      <sName symbol="GM">General Motors Corporation</sName>
      <description>General Motors Corp. is a diversified automotive business with 
                   additional interests in communications services, locomotives, finance 
                   and insurance. GM's automotive business designs, manufactures, and/or 
                   markets vehicles primarily in North America under the Chevrolet, Pontiac, 
                   GMC, Oldsmobile, Buick, Cadillac, Saturn and Hummer nameplates, and 
                   outside North America under the Opel, Vauxhall, Holden, Isuzu, Saab, 
                   Buick, Chevrolet, GMC and Cadillac nameplates. GM's communications 
                   services relate to its Hughes Electronics Corporation subsidiary, 
                   which includes digital entertainment, information and communications 
                   services, and satellite-based private business networks. GM also is 
                   engaged in the design, manufacturing and marketing of locomotives and 
                   heavy-duty transmissions. GM's financing and insurance operations are 
                   conducted primarily through General Motors Acceptance Corporation, which 
                   provides a broad range of financial services.
      </description>
      <category>Industrials</category>
      <link>http://www.gm.com</link>
      <year_high>68.17</year_high>
      <year_low>39.17</year_low>
      <pe_ratio>11.29</pe_ratio>
      <earnings>4.06</earnings>
      <yield>4.36</yield>
      <today open="46.67" high="47.00" low="44.53" current="46.67" vol="6.08" />
   </stock>

   <stock>
      <sName symbol="EK">Eastman Kodak Company</sName>
      <description>Eastman Kodak Company (Kodak) is engaged primarily in developing, 
                   manufacturing and marketing traditional and digital imaging products, 
                   services and solutions for consumers, professionals, healthcare 
                   providers, the entertainment industry and other commercial customers. 
                   The Company is a major participant in the "infoimaging" industry, 
                   which is composed of devices (digital cameras and personal data 
                   assistants), infrastructure (online networks and delivery systems for 
                   images) and services and media (software, film and paper enabling 
                   people to access, analyze and print images). Kodak uses its technology, 
                   market reach and a host of industry partnerships to provide products 
                   and services for customers that need the information-rich content that 
                   images contain.
      </description>
      <category>Industrials</category>
      <link>http://www.kodak.com</link>
      <year_high>47.30</year_high>
      <year_low>24.40</year_low>
      <pe_ratio>na</pe_ratio>
      <earnings>-0.13</earnings>
      <yield>6.29</yield>
      <today open="29.40" high="29.84" low="27.83" current="29.84" vol="3.16" />
   </stock>

   <stock>
      <sName symbol="R">Ryder Systems Incorporated</sName>
      <description>Ryder System, Inc. is a provider of logistics, supply chain and 
                   transportation management solutions worldwide. The Company operates 
                   in three reportable business segments: Fleet Management Solutions, 
                   which provides full-service leasing, commercial rental and programmed 
                   maintenance of trucks, tractors and trailers to customers, principally 
                   in the United States, Canada and the United Kingdom; Supply Chain 
                   Solutions, which provides comprehensive supply chain consulting and 
                   lead logistics management solutions that support customers' entire 
                   supply chains, from inbound raw materials through distribution of 
                   finished goods throughout North America, in Latin America, Europe and 
                   Asia, and Dedicated Contract Carriage, which provides vehicles and 
                   drivers as part of a dedicated transportation solution, principally 
                   in North America. 
      </description>
      <category>Transportation</category>
      <link>http://www.ryder.com</link>
      <year_high>31.09</year_high>
      <year_low>17.02</year_low>
      <pe_ratio>13.79</pe_ratio>
      <earnings>1.85</earnings>
      <yield>2.35</yield>
      <today open="25.62" high="26.29" low="24.93" current="25.23" vol="0.26" />
   </stock>

   <stock>
      <sName symbol="ABF">Airborne Freight Corporation</sName>
      <description>Airborne Freight Corporation is an air express company and air freight 
                   forwarder that expedites shipments of all sizes to destinations 
                   throughout the United States and most foreign countries. ABX Air, Inc., 
                   the Company's principal wholly owned subsidiary, provides domestic 
                   express cargo service and cargo service to Canada. The Company is the 
                   sole customer of ABX for this service. ABX also offers limited charter 
                   service. Airborne Express provides door-to-door express delivery of 
                   small packages and documents throughout the United States and to and 
                   from most foreign countries. The Company also acts as an international 
                   and domestic freight forwarder for shipments of any size.
      </description>
      <category>Transportation</category>
      <link>http://www.airborne.com</link>
      <year_high>23.34</year_high>
      <year_low>7.00</year_low>
      <pe_ratio>207.67</pe_ratio>
      <earnings>0.06</earnings>
      <yield>1.28</yield>
      <today open="12.80" high="13.18" low="11.90" current="13.00" vol="1.00" />
   </stock>

   <stock>
      <sName symbol="LUV">Southwest Airlines Corporation</sName>
      <description>Southwest Airlines Co. is a domestic airline that provides primarily 
                   short-haul, high-frequency, point-to-point, low-fare service. Southwest 
                   focuses principally on point-to-point, rather than hub-and-spoke service 
                   in markets with frequent, conveniently timed flights and low fares. 
                   The Company serves many conveniently located satellite or downtown 
                   airports such as Dallas Love Field, Houston Hobby, Chicago Midway, 
                   Baltimore-Washington International, Burbank, Manchester, Oakland, 
                   San Jose, Providence, Ft. Lauderdale/Hollywood and Long Island airports, 
                   which are typically less congested than other airlines' hub airports.
      </description>
      <category>Transportation</category>
      <link>http://www.southwest.com</link>
      <year_high>22.00</year_high>
      <year_low>11.25</year_low>
      <pe_ratio>25.46</pe_ratio>
      <earnings>0.54</earnings>
      <yield>0.07</yield>
      <today open="14.00" high="14.59" low="13.53" current="14.00" vol="4.03" />
   </stock>

   <stock>
      <sName symbol="CNI">Canadian National Railway Corporation</sName>
      <description>Canadian National Railway is the only rail network on the continent 
                   to connect three coasts: the Pacific, the Atlantic and the Gulf of 
                   Mexico. The Company derives revenue from seven business units. The 
                   Petroleum and Chemicals unit transports a wide range of commodities, 
                   including chemicals, plastics, petroleum and gas products. The Metals 
                   and Minerals unit primarily transports nonferrous base metals, steel, 
                   equipment and parts. The Forest Products unit transports various types 
                   of lumber, panels, wood chips, wood pulp, pulpwood, printing paper, 
                   linerboard and newsprint. The Coal unit transports thermal and 
                   metallurgical grades of coal. The Grain and Fertilizer primarily 
                   transports commodities grown in western Canada and the United States 
                   Midwest. The Intermodal unit consists of a domestic segment and an 
                   international segment that transport consumer and manufactured goods. 
                   The Automotive unit is a carrier of automotive products originating 
                   in southwestern Ontario and Michigan.
      </description>
      <category>Transportation</category>
      <link>http://www.cnrail.com</link>
      <year_high>53.75</year_high>
      <year_low>33.00</year_low>
      <pe_ratio>9.17</pe_ratio>
      <earnings>5.16</earnings>
      <yield>1.73</yield>
      <today open="47.70" high="48.14" low="46.63" current="47.19" vol="0.35" />
   </stock>

   <stock>
      <sName symbol="UNP">Union Pacific Corporation</sName>
      <description>Union Pacific Corporation operates primarily in the areas of rail 
                   transportation, through its indirect wholly owned subsidiary Union 
                   Pacific Railroad Company, and trucking, through its indirect wholly owned 
                   subsidiaries Overnite Transportation Company and Motor Cargo Industries, 
                   Inc. Union Pacific Railroad Company is a Class I railroad that operates 
                   in the United States, with over 33,000 route miles linking Pacific Coast 
                   and Gulf Coast ports to the Midwest and eastern United States gateways 
                   and several north/south corridors to key Mexican gateways. Overnite is 
                   a major interstate trucking company specializing in less-than-truckload 
                   (LTL) shipments. Motor Cargo is a western regional LTL carrier that 
                   provides service throughout 10 western states. The Company's other product 
                   lines are comprised of the corporate holding company, which largely 
                   supports the Railroad, Fenix LLC, affiliated technology companies and 
                   self-insurance activities.
      </description>
      <category>Transportation</category>
      <link>http://www.up.com</link>
      <year_high>59.70</year_high>
      <year_low>58.15</year_low>
      <pe_ratio>14.32</pe_ratio>
      <earnings>4.06</earnings>
      <yield>1.38</yield>
      <today open="59.00" high="59.70" low="58.20" current="59.32" vol="1.81" />
   </stock>

   <stock>
      <sName symbol="ED">Consolidated Edison Corporation</sName>
      <description>Consolidated Edison, Inc. (Con Edison) is the holding company of 
                   Consolidated Edison Company of New York, Inc. (Con Edison of New York) 
                   and Orange and Rockland Utilities, Inc. (OR). Con Edison's principal 
                   business segments are the regulated electric, gas and steam businesses 
                   of its utility subsidiaries, and the unregulated businesses of its other 
                   subsidiaries. Con Edison of New York provides electric service in all 
                   of New York City (except part of Queens) and most of Westchester County, 
                   an approximately 660-square-mile service area with a population of more 
                   than eight million. It also provides gas service in Manhattan, The Bronx 
                   and parts of Queens and Westchester, and steam service in part of 
                   Manhattan, and its utility subsidiaries provide electric service in 
                   southeastern New York and in adjacent sections of New Jersey and 
                   northeastern Pennsylvania, an approximately 1,350 square mile service 
                   area.
      </description>
      <category>Utilities</category>
      <link>http://www.conedison.com</link>
      <year_high>45.40</year_high>
      <year_low>35.50</year_low>
      <pe_ratio>11.76</pe_ratio>
      <earnings>3.16</earnings>
      <yield>5.98</yield>
      <today open="37.17" high="37.50" low="36.43" current="37.05" vol="1.22" />
   </stock>

   <stock>
      <sName symbol="AEP">American Electrical Power Company, Incorporated</sName>
      <description>American Electric Power Company, Inc. (AEP) is a public utility holding 
                   company that directly or indirectly owns domestic electric utility 
                   subsidiaries and varying percentages of other subsidiaries. The operating 
                   revenues of AEP and its subsidiaries are mostly derived from the marketing 
                   and trading of power and gas and the furnishing of electric service. The 
                   Company's operations are divided into three business segments: Wholesale, 
                   Energy Delivery and Other. The Wholesale Segment involves the generation 
                   of electricity for sale to retail and wholesale customers, the marketing 
                   and trading of electricity and gas worldwide, gas pipeline and storage 
                   services, and other energy supply related business. The Energy Delivery 
                   Segment is engaged in domestic electricity transmission and distribution. 
                   The Other Segment involves foreign electricity generation investments, 
                   foreign electricity distribution and supply investments, and 
                   telecommunication services.
      </description>
      <category>Utilities</category>
      <link>http://www.aep.com</link>
      <year_high>48.90</year_high>
      <year_low>33.02</year_low>
      <pe_ratio>12.98</pe_ratio>
      <earnings>2.74</earnings>
      <yield>6.75</yield>
      <today open="36.10" high="36.42" low="34.35" current="34.45" vol="2.67" />
   </stock>

   <stock>
      <sName symbol="PPL">PPL Corporation</sName>
      <description>PPL Corporation is an energy and utility holding company. Through its 
                   subsidiaries, PPL generates electricity in power plants in the 
                   northeastern and western United States, markets wholesale or retail 
                   energy primarily in the northeastern and western portions of the 
                   United States and in Canada; delivers electricity to nearly six million 
                   customers in the United States, United Kingdom and Latin America, and 
                   provides energy services for businesses in the mid-Atlantic and 
                   northeastern United States. PPL is organized in segments consisting of 
                   Supply, Delivery and International. In addition, certain corporate 
                   service functionsare provided by PPL Services, an unregulated subsidiary 
                   of PPL.
      </description>
      <category>Utilities</category>
      <link>http://www.pplresources.com</link>
      <year_high>53.45</year_high>
      <year_low>28.54</year_low>
      <pe_ratio>11.10</pe_ratio>
      <earnings>2.69</earnings>
      <yield>4.82</yield>
      <today open="30.05" high="30.62" low="29.40" current="30.50" vol="0.84" />
   </stock>

   <stock>
      <sName symbol="MRO">Marathon Oil Corporation</sName>
      <description>Marathon Oil Corporation is engaged in the worldwide exploration and 
                   production of crude oil and natural gas; domestic refining, marketing 
                   and transportation of crude oil and petroleum products, primarily 
                   through its 62%-owned subsidiary, Marathon Ashland Petroleum LLC (MAP), 
                   and other energy-related businesses. Marathon is conducting exploration 
                   and development activities in 11 countries. Refining, marketing and 
                   transportation operations are primarily conducted by MAP and its 
                   subsidiaries, including its wholly owned subsidiaries, Speedway 
                   SuperAmerica LLC and Marathon Ashland Pipe Line LLC. Marathon also owns 
                   interest in various pipeline systems that were not contributed to MAP. 
                   Marathon, through its wholly owned subsidiary, Marathon Power Company, 
                   Ltd., pursues development, construction, ownership and operation of 
                   integrated gas and electric power projects in the global electrical 
                   power market.
      </description>
      <category>Industrials</category>
      <link>http://www.marathon.com</link>
      <year_high>32.75</year_high>
      <year_low>23.28</year_low>
      <pe_ratio>8.36</pe_ratio>
      <earnings>2.86</earnings>
      <yield>3.85</yield>
      <today open="24.15" high="24.63" low="23.70" current="24.08" vol="1.84" />
   </stock>

   <stock>
      <sName symbol="AZO">Autozone Corporation</sName>
      <description>AutoZone, Inc. is a specialty retailer of automotive parts and 
                   accessories, primarily focusing on do-it-yourself customers. Each 
                   auto parts store carries an extensive product line for cars, vans and 
                   light trucks, including new and re-manufactured automotive hard parts, 
                   maintenance items and accessories. The Company also has a commercial 
                   sales program in the United States that provides commercial credit and 
                   prompt delivery of parts and other products to local repair garages, 
                   dealers and service stations. AutoZone does not sell tires or perform 
                   automotive repair or installation. In addition, the Company sells 
                   automotive diagnostic and repair information software through its ALLDATA 
                   subsidiary, and diagnostic and repair information through 
                   alldatadiy.com.
      </description>
      <category>Industrials</category>
      <link>http://www.autozone.com</link>
      <year_high>84.50</year_high>
      <year_low>38.07</year_low>
      <pe_ratio>22.12</pe_ratio>
      <earnings>3.04</earnings>
      <yield>na</yield>
      <today open="68.00" high="69.30" low="65.80" current="67.19" vol="1.59" />
   </stock>

</portfolio>



XSL
<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="html" version="4.0" />
  
  <xsl:template match="/">
    <html>
     
        <head>
          <title>Hardin Financial</title>
        </head>
        <body>
          <h1 align="center">Current Stock Values</h1>

          <table border="2" align="center">
            <tr>
              <th>Stock</th>
              <th>Current</th>
              <th>Open</th>
              <th>High</th>
              <th>Low</th>
              <th>Volume</th>
            </tr>
            
              <xsl:for-each select="portfolio/stock">
                
                <tr>
                <td>
                  <xsl:choose>
                    <xsl:when test="today/@current &lt; today/@open">
                      <img src="down.gif" />
                    </xsl:when>
                    <xsl:when test="today/@current &gt; today/@open">
                      <img src="up.gif" />
                    </xsl:when>
                    <xsl:when test="today/@current &lt; today/@open">
                      <img src="down.gif" />
                    </xsl:when>
                    <xsl:otherwise>
                      <img src="same.gif" />
                    </xsl:otherwise>
                  </xsl:choose>

                  <xsl:value-of select="sName/@symbol"/>
                </td>
           
                
                <xsl:apply-templates select="today/@open" />
                <xsl:apply-templates select="today/@high" />
                <xsl:apply-templates select="today/@low" />
                <xsl:apply-templates select="today/@current" />
                <xsl:apply-templates select="today/@vol" />
              </tr>
                
              </xsl:for-each>
            
          </table>
        
          <hr></hr>
          <hr></hr>
        
          <h1 align="center">Summary Information</h1>

          <xsl:apply-templates select="portfolio/stock/sName" />

          <xsl:apply-templates select="portfolio/stock/description" />


          <table border="10"  style="float:left" cellpadding="2" cellspacing="3">
            <tr>
              <td><b>Category</b></td>
              <td>
                
              </td>
            </tr>
            <tr>
              <td><b>Year High</b></td>
              <td>
                
              </td>
            </tr>
            <tr>
              <td><b>Year Low</b></td>
              <td>
                
              </td>
            </tr>
            <tr>
              <td><b>P/E Ratio</b></td>
              <td>
                
              </td>
            </tr>
            <tr>
              <td><b>Earnings</b></td>
              <td>
                
              </td>
            </tr>
            <tr>
              <td><b>Yield</b></td>
              <td>
                
              </td>
            </tr>
          </table>
      </body>
    
    </html>
  </xsl:template>

  <xsl:template match="@open|@high|@low|@current|@vol">
    <td>
      <xsl:value-of select="." />
    </td>
  </xsl:template>

  <xsl:template match="sName">
    <h3 style="clear: left">
      <xsl:value-of select="." />
    </h3>
  </xsl:template>

  <xsl:template match="description">
      <xsl:value-of select="." />
  </xsl:template>

  
  
</xsl:stylesheet>




Is This A Good Question/Topic? 0
  • +

Replies To: XML and XSLT Table and Description Help

#2 hugoriffic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 185
  • Joined: 16-September 09

Re: XML and XSLT Table and Description Help

Posted 28 November 2012 - 11:07 AM

Any help would be greatly appreciated. Thank you.

This post has been edited by hugoriffic: 28 November 2012 - 11:07 AM

Was This Post Helpful? 0
  • +
  • -

#3 hugoriffic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 185
  • Joined: 16-September 09

Re: XML and XSLT Table and Description Help

Posted 28 November 2012 - 11:26 AM

OK, so I got the tables and descriptions to work with the corresponding companies.
I have my tables floating left right where they should be, but my description sits above the table, not to the right hand side of it. I've tried float: right, text-align: right, align: right, and none of these move the text to the right of the tables. Any ideas as to how to move these over to the right??

Also, I'm still unable to populate the second column of the table with the appropriate information. Any help with that would be very helpful.
Was This Post Helpful? 0
  • +
  • -

#4 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5901
  • View blog
  • Posts: 12,804
  • Joined: 16-October 07

Re: XML and XSLT Table and Description Help

Posted 28 November 2012 - 11:32 AM

First, avoid for-each if you can help it. Second, there is a magic attribute in XSLT called "mode" that will allow you do break up how logic is applied to the same element.

By breaking down your templates into smaller chunks, it's easier to see what's going on.

<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:output method="html" version="4.0" />

	<xsl:template match="/">
		<html>
		<head><title>Hardin Financial</title></head>
		<body>
			<xsl:apply-templates select="portfolio" mode="current_stock" />
			<hr></hr>
			<hr></hr>
			<xsl:apply-templates select="portfolio" mode="summary" />
		</body>
		</html>
	</xsl:template>

	
	<xsl:template match="portfolio" mode="current_stock">
		<h1 align="center">Current Stock Values</h1>
		<table border="2" align="center">
			<tr><th>Stock</th><th>Current</th><th>Open</th><th>High</th><th>Low</th><th>Volume</th></tr>
			<xsl:apply-templates select="stock" mode="current_stock" />
		</table>
	</xsl:template>


	<xsl:template match="stock" mode="current_stock">
		<tr>
			<td>
				<xsl:choose>
					<xsl:when test="today/@current &lt; today/@open"><img src="down.gif" /></xsl:when>
					<xsl:when test="today/@current &gt; today/@open"><img src="up.gif" /></xsl:when>
					<xsl:when test="today/@current &lt; today/@open"><img src="down.gif" /></xsl:when>
					<xsl:otherwise><img src="same.gif" /></xsl:otherwise>
				</xsl:choose>
				<xsl:value-of select="sName/@symbol"/>
			</td>
			<xsl:apply-templates select="today/@open" />
			<xsl:apply-templates select="today/@high" />
			<xsl:apply-templates select="today/@low" />
			<xsl:apply-templates select="today/@current" />
			<xsl:apply-templates select="today/@vol" />
		</tr>
	</xsl:template>


	<xsl:template match="portfolio" mode="summary">
		<h1 align="center">Summary Information</h1>
		<xsl:apply-templates select="stock" mode="summary" />
	</xsl:template>


	<xsl:template match="stock" mode="summary">
		<xsl:apply-templates select="sName" />
		<xsl:apply-templates select="description" />
		<table border="10"  style="float:left" cellpadding="2" cellspacing="3">
			<tr><td><b>Category</b></td><td></td></tr>
			<tr><td><b>Year High</b></td><td></td></tr>
			<tr><td><b>Year Low</b></td><td></td></tr>
			<tr><td><b>P/E Ratio</b></td><td></td></tr>
			<tr><td><b>Earnings</b></td><td></td></tr>
			<tr><td><b>Yield</b></td><td></td></tr>
		</table>
	</xsl:template>


	<xsl:template match="today/@*">
		<td><xsl:value-of select="." /></td>
	</xsl:template>

	<xsl:template match="sName">
		<h3 style="clear: left"><xsl:value-of select="." />	</h3>
	</xsl:template>

	<xsl:template match="description">
		<xsl:value-of select="." />
	</xsl:template>

</xsl:stylesheet>



Note how apply-templates iterates over each of your stock nodes and isolates the logic in a different section.

Hope this helps.
Was This Post Helpful? 0
  • +
  • -

#5 hugoriffic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 185
  • Joined: 16-September 09

Re: XML and XSLT Table and Description Help

Posted 28 November 2012 - 11:59 AM

baavgai,
As for the "for-each" statements I am just following the instructors directions. I see where your code is much cleaner and more readable. The only issue I have left is how to populate the second column with the appropriate information. Everything else is in order and in it's proper place.
Was This Post Helpful? 0
  • +
  • -

#6 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5901
  • View blog
  • Posts: 12,804
  • Joined: 16-October 07

Re: XML and XSLT Table and Description Help

Posted 28 November 2012 - 12:05 PM

Just use value-of. You've already been doing it. The trick is being in the right place at the right time.

e.g.
<xsl:template match="stock" mode="summary">
	<h3 style="clear: left"><xsl:value-of select="sName" />	</h3>
	<p><xsl:value-of select="description" /></p>
	<table border="10"  style="float:left" cellpadding="2" cellspacing="3">
		<tr><td><b>Category</b></td><td><td><xsl:value-of select="category" /></td></tr>


Was This Post Helpful? 0
  • +
  • -

#7 hugoriffic  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 185
  • Joined: 16-September 09

Re: XML and XSLT Table and Description Help

Posted 28 November 2012 - 12:20 PM

OK, figured out how to populate the data within each column #2. So, assignment is completed.
One thing that bothers me though is that right below the tables I've been working on sits the next company name. I would like a bit of spacing there to give it a cleaner look. I've tried putting in <br /> tags to accomplish this but no matter where I stick it it does not work.
Any thoughts?

P.S. Thank you very much baavgai. You were of great help. You made me look at it from a new perspective and that got me out of my rut.

This post has been edited by hugoriffic: 28 November 2012 - 12:26 PM

Was This Post Helpful? 0
  • +
  • -

#8 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5901
  • View blog
  • Posts: 12,804
  • Joined: 16-October 07

Re: XML and XSLT Table and Description Help

Posted 28 November 2012 - 12:36 PM

Yeah, I saw that too. If you put your description in between <p></p> it should clear it up. All kinds of strange things can happen when you just have text lying around in an HTML document outside of tags.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1