John Smart Posted December 14, 2006 Share Posted December 14, 2006 Hi,I'm trying to get into using XML/XSL for displaying some tabular information from an Excel file.I've got my XML file, and an XSL file that work fine and display the data. The problem I have is that I would like to make the text in column 3 become links (ie Case Names such as Plant Movement plc), but not been able to work out how to do this so far. I've added my XML and XSL files below.Any help would be most appreciated, as my head is sore from banging it against a brick wall!XML File: <?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/xsl" href="undext.xsl"?><meadinkent><case><answer1>Engineering</answer1><answer2>Machinery Movement</answer2><answer3>Plant Movement plc</answer3><answer4>Moved about plant</answer4><answer5>Not well known</answer5><answer6>a</answer6><answer7>Price or Rating</answer7><answer8>John Smart</answer8><answer9>Everything</answer9><answer10>York Street</answer10><answer11>7533 3761</answer11><answer12>Write business</answer12><answer13>MAP acceptable</answer13><answer14>C and D</answer14><answer15>Engineering and Property</answer15></case><case><answer1>Property</answer1><answer2>BI</answer2><answer3>John Smart plc</answer3><answer4>Some stuff</answer4><answer5>Not well known</answer5><answer6>a</answer6><answer7>Price or Rating</answer7><answer8>John Smart</answer8><answer9>Everything</answer9><answer10>York Street</answer10><answer11>7533 3761</answer11><answer12>Write business</answer12><answer13>Learnt things</answer13><answer14>A</answer14><answer15>Property and Crime</answer15></case></meadinkent> XSL file: <?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <link rel='stylesheet' type='text/css' href='CaseStyle.css'></link> <body> <h2>CASE LEARNING LIBRARY</h2> <br /> <div class="kitetext">Use the buttons to select a Policy class to narrow down your selection.</div> <br /> <table class='grey'> <tr> <th>Business Line</th> <th>Business Class</th> <th>Case Name</th> <th>Referral Reason</th> <th>Action Taken</th> <th>Leaning Points</th> <th>Level</th> <th>Specific Subject</th> </tr> <xsl:for-each select="meadinkent/case"> <tr> <td><xsl:value-of select="answer1"/></td> <td><xsl:value-of select="answer2"/></td> <td><xsl:value-of select="answer3"/></td> <td><xsl:value-of select="answer4"/></td> <td><xsl:value-of select="answer12"/></td> <td><xsl:value-of select="answer13"/></td> <td><xsl:value-of select="answer14"/></td> <td><xsl:value-of select="answer15"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template></xsl:stylesheet> Link to comment Share on other sites More sharing options...
boen_robot Posted December 14, 2006 Share Posted December 14, 2006 O...K.... and where do the URLs come from?If you know the answer to that, then the way you do it would be simply <td><a href="{wherever the URLs come from}"><xsl:value-of select="answer3"/></a></td> Link to comment Share on other sites More sharing options...
John Smart Posted December 15, 2006 Author Share Posted December 15, 2006 Hi, thanks for responding.My URL's are coming from an element in my XML document (forgot I hadn't added them in at this point).so for instance <link>http://www.bbc.co.uk</link> in each <case>.I've now worked out how to add these links by using the following in my XSL file, but what I'd like to do is get it so that the page displays say BBC instead of the full URL address. Is this possible? <td> <xsl:for-each select="link"> <a> <xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute> <xsl:apply-templates /> </a> </xsl:for-each> </td> Again, any help appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now