Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2013
    Location
    Scotland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trying to not have hardcoded details

    Hi all,

    I have a XML file which has Events and Venues for the Commonwealth Games 2014. I use XSLT and ColdFusion to generate a HTML page which has a list of events which shows details and a image of the venue. In the XSL file the venue image and name is hardcoded .... I need to change this so it's not hardcoded so I have a couple of questions.

    First here is my code for both files -

    Here is my code for the XML:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- ?xml-stylesheet href="venues.xsl" type="text/xsl"? -->
    <games xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="games.xsd">
    		
    <!-- This is the list of events -->
    	<sport id="sp01">
    		<event>Ceremonies</event>
    		<discipline>Opening Ceremony</discipline>
    		<fromdate>2014-07-23</fromdate>
    		<todate>2014-07-23</todate>
    		<place>Celtic Park, Glasgow</place>
    	</sport>
    				
    	<sport id="sp02">
    		<event>Ceremonies</event>
    		<discipline>Closing Ceremony</discipline>
    		<fromdate>2014-08-03</fromdate>
    		<todate>2014-08-03</todate>
    		<place>Hampden Park, Glasgow</place>
    	</sport>
    
    	<sport id="sp03">
    		<event>Aquatics</event>
    		<discipline>Diving</discipline>
    		<fromdate>2014-07-30</fromdate>
    		<todate>2014-08-02</todate>
    		<place>Royal Commonwealth Pool, Edinburgh</place>
    	</sport>
    
    	<sport id="sp04">
    		<event>Aquatics</event>
    		<discipline>Swimming</discipline>
    		<fromdate>2014-07-24</fromdate>
    		<todate>2014-07-29</todate>
    		<place>Tollcross International Swimming Centre, Glasgow</place>
    	</sport>
    
    	<sport id="sp05">
    		<event>Athletics</event>
    		<discipline>Marathon</discipline>
    		<fromdate>2014-07-27</fromdate>
    		<todate>2014-07-27</todate>
    		<place>Glasgow City Marathon Course, Glasgow</place>
    	</sport>
    
    	<sport id="sp06">
    		<event>Athletics</event>
    		<discipline>Track and Field</discipline>
    		<fromdate>2014-07-23</fromdate>
    		<todate>2014-08-02</todate>
    		<place>Hampden Park, Glasgow</place>
    	</sport>
    
    	<sport id="sp07">
    		<event>Cycling</event>
    		<discipline>Mountain Bike</discipline>
    		<fromdate>2014-07-29</fromdate>
    		<todate>2014-07-29</todate>
    		<place>Cathkin Braes Trails, Glasgow</place>
    	</sport>
    
    	<sport id="sp08">
    		<event>Cycling</event>
    		<discipline>Time Trial and Road Race</discipline>
    		<fromdate>2014-07-31</fromdate>
    		<todate>2014-08-03</todate>
    		<place>Glasgow City Time Trial and Road Courses, Glasgow</place>
    	</sport>
    
    	<sport id="sp09">
    		<event>Cycling</event>
    		<discipline>Track</discipline>
    		<fromdate>2014-07-24</fromdate>
    		<todate>2014-07-27</todate>
    		<place>Sir Chris Hoy Velodrome, Glasgow</place>
    	</sport>
    
    	<sport id="sp10">
    		<event>Boxing</event>
    		<discipline>Knockout Stage</discipline>
    		<fromdate>2014-07-25</fromdate>
    		<todate>2014-08-01</todate>
    		<place>Scottish Exhibition and Conference Centre, Glasgow</place>
    	</sport>
    
    	<sport id="sp11">
    		<event>Boxing</event>
    		<discipline>Finals</discipline>
    		<fromdate>2014-08-02</fromdate>
    		<todate>2014-08-02</todate>
    		<place>The Hydro, Glasgow</place>
    	</sport>	
    				
    	<sport id="sp12">
    		<event>Gymnastics</event>
    		<discipline>Artistic</discipline>
    		<fromdate>2014-07-28</fromdate>
    		<todate>2014-08-01</todate>
    		<place>The Hydro, Glasgow</place>
    	</sport>
    
    	<sport id="sp13">
    		<event>Gymnastics</event>
    		<discipline>Rythmic</discipline>
    		<fromdate>2014-07-24</fromdate>
    		<todate>2014-07-26</todate>
    		<place>The Hydro, Glasgow</place>
    	</sport>
    
    
    <!-- This is the list of venues -->
    <venue id="ven01">
    	<name>Royal Commonwealth Pool</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Royal-Commonwealth-Pool-bb6.jpg</image>
    	<about>With Arthurs Seat outside and award-winning architecture inside, Edinburghs Royal Commonwealth Pool offers a dramatic setting for the Diving competitions. The original Royal Commonwealth Pool was designed by RMJM Architects in 1967 for the Edinburgh 1970 Commonwealth Games and it was used again for Edinburgh 1986. Owned by City of Edinburgh Council, the venue has undergone major refurbishment, including the upgrading of the diving pool todate meet international standards.</about>
    	<address>Dalkeith Road</address>
    	<city>Edinburgh</city>
    	<postcode>EH16 5BB</postcode>
    	<telephone>0131 667 7211</telephone>
    	<email>info.rcp@edinburghleisure.co.uk</email>
    	<latitude>55.93901</latitude>
    	<longitude>-3.172781</longitude>
    </venue>
    		
    <venue id="ven02">
    	<name>Tollcross International Swimming Centre</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Tollcross-Aquatic-Centre-0a2.jpg</image>
    	<about>The drama of the Swimming competitions will be played out at Tollcross International Swimming Centre. The venue is owned by Glasgow City Council and has been extensively refurbished and extended. The existing 50 metre, 10-lane pool has been joined by a new 50m, six-lane warm-up and training pool, ensuring world-class facilities for the Games.</about>
    	<address>350 Wellshot Road</address>
    	<city>Glasgow</city>
    	<postcode>G32 7QR</postcode>
    	<telephone>0141 276 8200</telephone>
    	<email>info@glasgowlife.org.uk</email>
    	<latitude>55.845807</latitude>
    	<longitude>-4.177086</longitude>
    </venue>
    		
    <venue id="ven03">
    	<name>Glasgow City Marathon Course</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Glasgow-36106.jpg</image>
    	<about>Endurance will be tested in the Marathon, which will take in the sights of Glasgow as part of a 42.195km city course.</about>
    	<address>Glasgow City Council, 231 George Street</address>
    	<city>Glasgow</city>
    	<postcode>G1 1RX</postcode>
    	<telephone>0141 287 9171</telephone>
    	<email>les@glasgow.gov.uk</email>
    	<latitude>55.864716</latitude>
    	<longitude>-4.251766</longitude>
    </venue>		
    		
    <venue id="ven04">
    	<name>Hampden Park</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Hampden-Park-753.jpg</image>
    	<about>At one time the worlds largest stadium, Glasgows famous Hampden Park will play host todate the Track and Field Athletics competitions and the XX Commonwealth Games Closing Ceremony. Hampden Park is an iconic place not only for Glaswegians, but also for all Scots as it is home todate the national football team.</about>
    	<address>Hampden Park</address>
    	<city>Glasgow</city>
    	<postcode>G42 9BA</postcode>
    	<telephone>0141 620 4000</telephone>
    	<email>info@hampdenpark.co.uk</email>
    	<latitude>55.825973</latitude>
    	<longitude>-4.252238</longitude>
    </venue>
    		
    <venue id="ven05">
    	<name>Cathkin Braes Trails</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Cathkin-Braes-Country-Park--060.jpg</image>
    	<about>The Cathkin Braes Mountain Bike Trails are an exciting new addition todate Glasgows sporting landscape. Located on the citys south side, just 15 minutes fromdate the Athletes Village, the trails will host the Mountain Bike competitions and have been created in collaboration with expert designers.</about>
    	<address>Glasgow City Council, 231 George Street</address>
    	<city>Glasgow</city>
    	<postcode>G1 1RX</postcode>
    	<telephone>0141 287 9171</telephone>
    	<email>les@glasgow.gov.uk</email>
    	<latitude>55.795371</latitude>
    	<longitude>-4.223088</longitude>
    </venue>
    		
    <venue id="ven06">
    	<name>Glasgow City Time Trial and Road Courses</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Kelvingrove%20Art%20Gallery_0.jpg</image>
    	<about>Road Race and Time Trial events will hit the open roads of Glasgow, using specific road circuit courses. They will be taking the tourist route through Glasgow, but forgive them if they don not pause todate admire the architecture. When you are travelling at these speeds, all you can see is the finish line.</about>
    	<address>Glasgow City Council, 231 George Street</address>
    	<city>Glasgow</city>
    	<postcode>G1 1RX</postcode>
    	<telephone>0141 287 9171</telephone>
    	<email>les@glasgow.gov.uk</email>
    	<latitude>55.859418</latitude>
    	<longitude>-4.263825</longitude>
    </venue>
    		
    <venue id="ven07">
    	<name>Sir Chris Hoy Velodrome</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Sir-Chris-Hoy-Velodrome--65e.jpg</image>
    	<about>The Velodrome is named in honour of the UKs most successful Gold-medal winning Olympian and Scottish Commonwealth Games champion. Its 250-metre track has been designed by Ralph Schuermann, one of the worlds foremost track designers.</about>
    	<address>Emirates Arena, 1000 London Road</address>
    	<city>Glasgow</city>
    	<postcode>G40 3HG</postcode>
    	<telephone>0141 287 7000</telephone>
    	<email>commonwealtharena@glasgowlife.org.uk</email>
    	<latitude>55.847373</latitude>
    	<longitude>-4.207982</longitude>
    </venue>
    		
    <venue id="ven08">
    	<name>Celtic Park</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/venue_celticpark_hero_final.jpg</image>
    	<about>Celtic Park will host the Glasgow 2014 Commonwealth Games Opening Ceremony. On 23 July 2014, this is place athletes fromdate throughout the Commonwealth community will celebrate their journey todate the Games and officially begin their 11-day quest for victodatery.</about>
    	<address>Celtic Park</address>
    	<city>Glasgow</city>
    	<postcode>G40 3RE</postcode>
    	<telephone>0871 226 1888</telephone>
    	<email>rkelly@celticfc.co.uk</email>
    	<latitude>55.849819</latitude>
    	<longitude>-4.205557</longitude>
    </venue>
    		
    <venue id="ven09">
    	<name>The Hydro</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/SECC%20Precinct%20venue.jpg</image>
    	<about>Opened in 1985, the SECC is located on the banks of the River Clyde and is one of Scotlands most visited venues. The precinct, which already boasts the large-scale SECC Exhibition Halls and the famous Clyde Auditodaterium (known as the Armadillo due todate its overlapping, shell-like structure), will now also see the addition of The SSE Hydro. Due todate open in late 2013 , The SSE Hydro has been designed by internationally-renowned architect Sir Norman Foster todate ensure that its amphitheatre-style arena is perfect for the sports programme.</about>
    	<address>Exhibition Way</address>
    	<city>Glasgow</city>
    	<postcode>G3 8YW</postcode>
    	<telephone>0141 248 3000</telephone>
    	<email>info@secc.co.uk</email>
    	<latitude>55.860297</latitude>
    	<longitude>-4.285165</longitude>
    </venue>
    
    <venue id="ven10">
    	<name>Scottish Exhibition and Conference Centre</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/SECC%5B1%5D.jpg</image>
    	<about>Opened in 1985, the SECC is located on the banks of the River Clyde and is one of Scotlands most visited venues. The precinct, which already boasts the large-scale SECC Exhibition Halls and the famous Clyde Auditodaterium (known as the Armadillo due todate its overlapping, shell-like structure), will now also see the addition of The SSE Hydro. Due todate open in late 2013 , The SSE Hydro has been designed by internationally-renowned architect Sir Norman Foster todate ensure that its amphitheatre-style arena is perfect for the sports programme.</about>
    	<address>Exhibition Way</address>
    	<city>Glasgow</city>
    	<postcode>G3 8YW</postcode>
    	<telephone>0141 248 3000</telephone>
    	<email>info@secc.co.uk</email>
    	<latitude>55.861164</latitude>
    	<longitude>-4.289027</longitude>
    </venue>
    
    </games>
    Here is my code for the XSL:
    Code:
    <?xml version="1.0"  encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml"  version="1.0" omit-xml-declaration="yes" indent="yes" media-type="text/html"/> 
      
    <xsl:template match="/">
    <html>
    	<head>
    	<link rel="stylesheet" href="games.css" type="text/css"/>
    		<title>Commonwealth Games 2014 Events</title>		
    	</head>
    	
    <body>
    			
    	<div id="main">
    		<br/>
    		<h2>Commonwealth Games 2014 Event Information</h2>
    		<hr/>
    		<xsl:apply-templates select="/games/sport"/>
    	</div>
    	
    </body>
    </html>
    
    </xsl:template>
    
    <xsl:template match="sport">
    
    	<div id="sport">
    		<hr/>
    		<br/>
    		<b>Event: </b><xsl:value-of select="event"/>
    		<br/>
    		<br/>
    		<b>Discipline: </b><xsl:value-of select="discipline"/>
    		<br/>
    		<br/>
    		<b>From: </b><xsl:value-of select="fromdate"/>
    		<br/>
    		<br/>
    		<b>To: </b><xsl:value-of select="todate"/>
    		<br/>
    		<br/>
    		<xsl:element name="img">
    		<xsl:attribute name="src">http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Sir-Chris-Hoy-Velodrome--65e.jpg</xsl:attribute>
    		<xsl:attribute name="alt">Sir Chris Hoy Velodrome, Glasgow</xsl:attribute>
    		</xsl:element>
    		<br/>
    		<b>Venue: </b><xsl:value-of select="place"/>
    		<br/>
    		<br/>
    	</div>
    		
    </xsl:template>
    
    </xsl:stylesheet>
    First question:
    In the XML <sport> section I need to change the <place> to an ID so it doesn't have a hardcoded name which corresponds to the <name> in the <venue> section at the lower half of the XML. How do I do this?

    Second Question:
    In the XSL I have an element for "img" which brings up the venue image but this is hardcoded at the moment so when my list of events and venues are shown on the HTML all the event details are correct but the images all show 1 venue.

    Here is an image:


    I need the XSL to have the "img" and venue name not hardcoded so they show the relevent image and name which corresponds to the event. How do I do this?

    Thanks,
    Hopefully you understand what I am trying to do.

  • #2
    New to the CF scene
    Join Date
    Nov 2013
    Location
    Scotland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can nobody help with this at all?

    Been trying to sort this out for ages and my uni work has to be in for friday.

  • #3
    New to the CF scene
    Join Date
    Nov 2013
    Location
    Scotland
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well I have managed to sort most of this myself but cannot get an image to show. I have changed a lot of stuff.

    Here is example of my code:
    Code:
    <games xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="games.xsd">
    		
    <!-- This is the list of events -->
    	<sport id="01">
    		<event>Ceremonies</event>
    		<discipline>Opening Ceremony</discipline>
    		<fromdate>2014-07-23</fromdate>
    		<todate>2014-07-23</todate>
    		<place>Celtic Park</place>
    	</sport>
    				
    	<sport id="02">
    		<event>Ceremonies</event>
    		<discipline>Closing Ceremony</discipline>
    		<fromdate>2014-08-03</fromdate>
    		<todate>2014-08-03</todate>
    		<place>Hampden Park</place>
    
    <venue id="04">
    	<name>Hampden Park</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/Hampden-Park-753.jpg</image>
    	<alt>Image of Hampden Park</alt>
    	<about>At one time the worlds largest stadium, Glasgows famous Hampden Park will play host todate the Track and Field Athletics competitions and the XX Commonwealth Games Closing Ceremony. Hampden Park is an iconic place not only for Glaswegians, but also for all Scots as it is home todate the national football team.</about>
    	<address>Hampden Park</address>
    	<city>Glasgow</city>
    	<postcode>G42 9BA</postcode>
    	<telephone>0141 620 4000</telephone>
    	<email>info@hampdenpark.co.uk</email>
    	<latitude>55.825973</latitude>
    	<longitude>-4.252238</longitude>
    </venue>
    
    <venue id="08">
    	<name>Celtic Park</name>
    	<image>http://downloads.glasgow2014.com/sites/default/files/styles/lead-listing/public/images/venue_celticpark_hero_final.jpg</image>
    	<alt>Image of Celtic Park</alt>
    	<about>Celtic Park will host the Glasgow 2014 Commonwealth Games Opening Ceremony. On 23 July 2014, this is place athletes fromdate throughout the Commonwealth community will celebrate their journey todate the Games and officially begin their 11-day quest for victodatery.</about>
    	<address>Celtic Park</address>
    	<city>Glasgow</city>
    	<postcode>G40 3RE</postcode>
    	<telephone>0871 226 1888</telephone>
    	<email>rkelly@celticfc.co.uk</email>
    	<latitude>55.849819</latitude>
    	<longitude>-4.205557</longitude>
    </venue>
    I have a list of sports and when you click on that sport it brings up the details from <sport> section at the top.

    What I want is when the <place> on this page shows for example 'Celtic Park' I want it to match with this in the <venue> section and bring up the image from the <image> tag.

    My lecturer said I could change <place> to an id which matches the <venue id> but am not sure how to do this.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •