Jump to content

Help with XSLT to HTML

Recommended Posts

I'm having a hard time dealing with footnotes as well as figuring out how to apply a unit and a source attribute to the table I've created.


I need to take the data from the XML file and convert it to HTML to duplicate the html file I've attached.


The unit attribute is applied to the area column in the table and the source attribute is an image that is applied to the map table.


Since I can't upload the XSL file for some reason, I'll put the code in the post. I've looked through the HTML code to try and get a few clues, but I'm completely stumped. I'll also bold a section that stopped working all of a sudden.


<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" omit-xml-declaration="yes" encoding="utf-8" indent="yes" doctype-system="about:legacy-compat" /> <xsl:template match="/"> <html> <head> <title>Washington Counties</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="counties"> <h1>Washington Counties</h1> <p> <a href="{./@source}"> Source </a> </p> <table border="1" style="border-collapse:collapse;"> <tr> <th>County</th> <th>INCITS</th> <th>County Seat</th> <th>Established</th> <th>Origin</th> <th>Etymology</th> <th>Population</th> <th>Area</th> <th>Map</th> </tr> <xsl:for-each select="county"> <xsl:sort select="established" data-type="text" /> <tr> <td id="{@county}"> <a href="{name/@href}"> <xsl:value-of select="name" /> </a> </td> <td id="{@county}"> <a href="{incits/@href}"> <xsl:value-of select="incits" /> </a> </td> <td id="{@county}"> <a href="{countySeat/@href}" > <xsl:value-of select="countySeat" /> </a> </td> <td> <xsl:value-of select="established"/> </td> <td> <xsl:value-of select="origin"/> </td> <td id="{@county}"> <a href="{etymology/@href}" > <xsl:copy-of select="etymology" /> </a> </td> <td> <xsl:value-of select="population"/> </td> <td> <xsl:value-of select="area"/> </td> <td id="{county}"> <a img="{map/@img}"> <xsl:copy-of select="map"/> </a> </td> </tr> </xsl:for-each> </table> <h4>Footnotes</h4> </xsl:template> </xsl:stylesheet>



Edited by ChaosDecides
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...