Advertisement

01.17.2008 at 03:17AM PST, ID: 23089814
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.0

Convering XML output to HTML

Asked by nicky2k in Extensible Markup Language (XML), Cold Fusion Markup Language

Tags:

The following code produces an HTML-like document from XML. What I want to do, is save the resulting HTML if produces.
1. Is this possible with CFMX
2. Is it possible at all?

Thanks.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="nutrition">
<html>
<head>
	<title>Nutrition Facts Summary</title>
</head>
<body>
<h2 align="center">Nutrition Facts Summary</h2>
<p>Here are summaries of nutrition facts for several foods.
They are based on these daily values:</p>
<xsl:apply-templates select="daily-values"/>
<hr width="80%" />
<xsl:apply-templates select="food"/>
</body>
</html>
</xsl:template>
 
<xsl:template match="daily-values">
<ul>
<li>Fat
	<ul>
	<li>Total: <xsl:value-of select="total-fat"/><xsl:value-of select="total-fat/@units"/></li>
	<li>Saturated: <xsl:value-of select="saturated-fat"/><xsl:value-of select="saturated-fat/@units"/></li>
	</ul>
</li>
<li>Cholesterol: <xsl:value-of select="cholesterol"/><xsl:value-of select="cholesterol/@units"/></li>
<li>Sodium: <xsl:value-of select="sodium"/><xsl:value-of select="sodium/@units"/></li>
<li>Carbohydrates: <xsl:value-of select="carb"/><xsl:value-of select="carb/@units"/></li>
<li>Fiber: <xsl:value-of select="fiber"/><xsl:value-of select="fiber/@units"/></li>
<li>Protein: <xsl:value-of select="protein"/><xsl:value-of select="protein/@units"/></li>
</ul>
</xsl:template>
 
<xsl:template match="food">
<h2><xsl:value-of select="name"/><xsl:text> </xsl:text>
	<i style="font-size:80%">(<xsl:value-of select="mfr"/>)</i></h2>
<p>Serving size: <xsl:value-of select="serving"/><xsl:value-of select="serving/@units"/><br />
Calories: <xsl:value-of select="calories/@total"/> /
Calories from fat: <xsl:value-of select="calories/@fat"/></p>
<table border="1">
<tr><th>Amount/Serving</th><th>%Daily Value</th></tr>
<xsl:call-template name="info-row">
	<xsl:with-param name="msg">Total Fat</xsl:with-param>
	<xsl:with-param name="node" select="total-fat"/>
</xsl:call-template>
 
<xsl:call-template name="info-row">
	<xsl:with-param name="msg">Saturated Fat</xsl:with-param>
	<xsl:with-param name="node" select="saturated-fat"/>
</xsl:call-template>
 
<xsl:call-template name="info-row">
	<xsl:with-param name="msg">Cholesterol</xsl:with-param>
	<xsl:with-param name="node" select="cholesterol"/>
</xsl:call-template>
 
<xsl:call-template name="info-row">
	<xsl:with-param name="msg">Sodium</xsl:with-param>
	<xsl:with-param name="node" select="sodium"/>
</xsl:call-template>
 
<xsl:call-template name="info-row">
	<xsl:with-param name="msg">Total Carbohydrates</xsl:with-param>
	<xsl:with-param name="node" select="carb"/>
</xsl:call-template>
 
<xsl:call-template name="info-row">
	<xsl:with-param name="msg">Dietary Fiber</xsl:with-param>
	<xsl:with-param name="node" select="fiber"/>
</xsl:call-template>
 
<xsl:call-template name="info-row">
	<xsl:with-param name="msg">Protein</xsl:with-param>
	<xsl:with-param name="node" select="protein"/>
</xsl:call-template>
</table>
<p align="center">
Vitamin A <xsl:value-of select="vitamins/a"/>%
<xsl:text disable-output-escaping="yes">&middot;</xsl:text>
Vitamin C <xsl:value-of select="vitamins/c"/>%
<xsl:text disable-output-escaping="yes">&middot;</xsl:text>
Calcium <xsl:value-of select="minerals/ca"/>%
<xsl:text disable-output-escaping="yes">&middot;</xsl:text>
Iron <xsl:value-of select="minerals/fe"/>%
</p>
</xsl:template>
 
<xsl:template name="info-row">
<xsl:param name="msg"/>
<xsl:param name="node"/>
<tr><td><b><xsl:value-of select="$msg"/><xsl:text> </xsl:text>
<xsl:value-of select="$node"/><xsl:value-of select="/nutrition/daily-values/*[name(.)=name($node)]/@units"/></b>
</td>
<td align="right">
<xsl:value-of select="round(100 * $node div /nutrition/daily-values/*[name(.)=name($node)])"/><xsl:text>%</xsl:text>
</td></tr>
</xsl:template>
 
</xsl:stylesheet>
[+][-]01.17.2008 at 05:34AM PST, ID: 20681037

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.17.2008 at 05:55AM PST, ID: 20681230

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.17.2008 at 08:52AM PST, ID: 20682989

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.17.2008 at 03:06PM PST, ID: 20686480

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Extensible Markup Language (XML), Cold Fusion Markup Language
Tags: output
Sign Up Now!
Solution Provided By: Plucka
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628