XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 20th, 2004, 10:52 AM
mckearners mckearners is offline
mckearners
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 mckearners User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via MSN to mckearners
XSLT: Parsing tags with the same name

I'm new to XML/XSLT and I'm a bit stuck. I have the following piece of XML:
Code:
<projects>
  <project>
    <vpmicode>12345</vpmicode>
    <bpm>Jim Beam</bpm>
    <project_title>Proj 1</project_title>
    <hlr_provided>False</hlr_provided>
    <rrb_date>21.03.2004</rrb_date>
    <no_visits>1</no_visits>
    <p_billing>True</p_billing>
    <p_crm>False</p_crm>
    <p_portal>False</p_portal>
    <p_erp>False</p_erp>
    <p_reporting>False</p_reporting>
    <p_nm>False</p_nm>
    <p_cn>False</p_cn>
    <p_net>False</p_net>
    <eval_conf>1</eval_conf>
    <rfp_required>False</rfp_required>
    <fes_complexity>0</fes_complexity>
    <eval_cost>2000</eval_cost>
    <proj_size>1</proj_size>
    <effort_type>1</effort_type>
    <reqstombox>01.01.2004</reqstombox>
    <fesdate>01.01.2004</fesdate>
    <comments>
      <comment>Comment 1</comment>
      <comment>Comment 2</comment>
      <comment>Comment 3</comment>
      <comment>Comment 7</comment>
      <comment>Comment 9</comment>
    </comments>
  </project>
...etc.

I have an xslt template trying to parse this.  What I don't know how to do is parse the <comment> tags as they have the same name.  Anyone got an easy solution for a junior programmer?  
Here's the xslt:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="projects">
<HEAD>
<STYLE type='text/css'>
H1 {color=black;font-size:16pt;font-style:bold}
TD {color=green;font-size:10pt}
TH {color=red;font-size:10pt;align=left}
</STYLE>
</HEAD>
	<HTML>
		<BODY>
			<FONT face='Tahoma' size='1'>
			<H1>Technical Process Statistics</H1>
			<TABLE>
			<TR>
			<span style='color:red'>
			<TH>VPMI Code</TH>
			<TH>BPM</TH>
			<TH>Project Title</TH>
			<TH>HLR</TH>
			<TH>T-PIA Date</TH>
			<TH>No. Visits</TH>
			<TH>Eval. Cof.</TH>
			<TH>RFP</TH>
			<TH>Cost</TH>
			<TH>Size</TH>
			<TH>Effort Type</TH>
			<TH>Requirements Delivered</TH>
			<TH>Feasibility Date</TH>
			</span>	
			</TR>
			</TABLE>
			
			<FONT color='black'>
			<xsl:for-each select="project">
			<TABLE>
				<TR>
				<TD>
				<xsl:value-of select="vpmicode"/>
				</TD>
				<TD>
				<xsl:value-of select="bpm"/>
				</TD>
				<TD>
				<xsl:value-of select="project_title"/>
				</TD>
				<TD>
				<xsl:choose>
				<xsl:when test="hlr_provided = 'False'">
					No
				</xsl:when>
				<xsl:otherwise>
					Yes
				</xsl:otherwise>
				</xsl:choose>
				</TD>
				<TD><xsl:value-of select="rrb_date"/></TD>
				<TD><xsl:value-of select="no_visits"/></TD>
				<TD>
				<xsl:choose>
					<xsl:when test="eval_conf = 0">
						Low
					</xsl:when>
					<xsl:when test="eval_conf = 1">
						Medium
					</xsl:when>
					<xsl:otherwise>
						High
					</xsl:otherwise>
				</xsl:choose>
				</TD>
				<TD>
				<xsl:choose>
					<xsl:when test="rfp_required = 'False'">No</xsl:when>
					<xsl:otherwise>Yes</xsl:otherwise>
				</xsl:choose>
				</TD>
				<TD><xsl:value-of select="eval_cost"/></TD>
				<TD>
				<xsl:choose>
					<xsl:when test='proj_size = 1'>Small</xsl:when>
					<xsl:when test='proj_size = 2'>Medium</xsl:when>
					<xsl:when test='proj_size = 3'>Large</xsl:when>
					<xsl:otherwise>N/A</xsl:otherwise>
				</xsl:choose>
				</TD>
				<TD>
				<xsl:choose>
					<xsl:when test='effort_type = 1'>Config Change</xsl:when>
					<xsl:when test='effort_type = 2'>Enhancement</xsl:when>
					<xsl:otherwise>Project</xsl:otherwise>
				</xsl:choose>
				</TD>
				<TD><xsl:value-of select="reqstombox"/></TD>
				<TD><xsl:value-of select="fesdate"/></TD>
			</TR>
			</TABLE>
			<TABLE>
			<TR><TD>Comments</TD></TR>
			<TR><TD><xsl:value-of select="comments/comment"/></TD>
			</TR>
			</TABLE> 
			</xsl:for-each>			
			</FONT>
			
		</FONT>
		</BODY>
	</HTML>
</xsl:template>

</xsl:stylesheet>

Last edited by drgroove : April 20th, 2004 at 04:22 PM. Reason: added code tags; disabled smilies

Reply With Quote
  #2  
Old April 20th, 2004, 12:15 PM
jharnois's Avatar
jharnois jharnois is offline
mod_dev_shed
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Sep 2002
Location: Atlanta, GA
Posts: 14,445 jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level)jharnois User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 2 Days 14 h 13 m 44 sec
Reputation Power: 812
Code:
<TR><TD>Comments</TD></TR>
<TR><TD><xsl:for-each select="comments"><xsl:value-of select="comment" /><br /></xsl:for-each></TD></TR>
FYI: tags are wonderful things. Please use them.
__________________
# Jeremy

Explain your problem instead of asking how to do what you decided was the solution.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSLT: Parsing tags with the same name


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT