Jump to content

Help with XSLT to HTML


ChaosDecides

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>

WashingtonCounties.html

WashingtonCounties.xml

Edited by ChaosDecides
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...