Skip to content

Instantly share code, notes, and snippets.

@andrewminton
Created April 9, 2017 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewminton/523bc6bf8b40c2f8913574c723d93ccf to your computer and use it in GitHub Desktop.
Save andrewminton/523bc6bf8b40c2f8913574c723d93ccf to your computer and use it in GitHub Desktop.
<data>
<hello>paste your xml here</hello>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common"
xmlns:date="http://exslt.org/dates-and-times"
exclude-result-prefixes="exsl date" version="1.0">
<xsl:variable name="uk-counties">
<countries name="United Kingdom">
<country name="England">
<county>Bedfordshire</county>
<county>Berkshire</county>
<county>Bristol</county>
<county>Buckinghamshire</county>
<county>Cambridgeshire</county>
<county>Cheshire</county>
<county>City of London</county>
<county>Cornwall</county>
<county>Cumbria</county>
<county>Derbyshire</county>
<county>Devon</county>
<county>Dorset</county>
<county>Durham</county>
<county>East Riding of Yorkshire</county>
<county>East Sussex</county>
<county>Essex</county>
<county>Gloucestershire</county>
<county>Greater London</county>
<county>Greater Manchester</county>
<county>Hampshire</county>
<county>Herefordshire</county>
<county>Hertfordshire</county>
<county>Isle of Wight</county>
<county>Kent</county>
<county>Lancashire</county>
<county>Leicestershire</county>
<county>Lincolnshire</county>
<county>Merseyside</county>
<county>Norfolk</county>
<county>North Yorkshire</county>
<county>Northamptonshire</county>
<county>Northumberland</county>
<county>Nottinghamshire</county>
<county>Oxfordshire</county>
<county>Rutland</county>
<county>Shropshire</county>
<county>Somerset</county>
<county>South Yorkshire</county>
<county>Staffordshire</county>
<county>Suffolk</county>
<county>Surrey</county>
<county>Tyne and Wear</county>
<county>Warwickshire</county>
<county>West Midlands</county>
<county>West Sussex</county>
<county>West Yorkshire</county>
<county>Wiltshire</county>
<county>Worcestershire</county>
</country>
<country name="Scotland">
<county>Aberdeenshire</county>
<county>Angus</county>
<county>Argyllshire</county>
<county>Ayrshire</county>
<county>Banffshire</county>
<county>Berwickshire</county>
<county>Buteshire</county>
<county>Cromartyshire</county>
<county>Caithness</county>
<county>Clackmannanshire</county>
<county>Dumfriesshire</county>
<county>Dunbartonshire</county>
<county>East Lothian</county>
<county>Fife</county>
<county>Inverness-shire</county>
<county>Kincardineshire</county>
<county>Kinross</county>
<county>Kirkcudbrightshire</county>
<county>Lanarkshire</county>
<county>Midlothian</county>
<county>Morayshire</county>
<county>Nairnshire</county>
<county>Orkney</county>
<county>Peeblesshire</county>
<county>Perthshire</county>
<county>Renfrewshire</county>
<county>Ross-shire</county>
<county>Roxburghshire</county>
<county>Selkirkshire</county>
<county>Shetland</county>
<county>Stirlingshire</county>
<county>Sutherland</county>
<county>West Lothian</county>
<county>Wigtownshire</county>
</country>
<country name="Wales">
<county>Anglesey</county>
<county>Brecknockshire</county>
<county>Caernarfonshire</county>
<county>Carmarthenshire</county>
<county>Cardiganshire</county>
<county>Denbighshire</county>
<county>Flintshire</county>
<county>Glamorgan</county>
<county>Merioneth</county>
<county>Monmouthshire</county>
<county>Montgomeryshire</county>
<county>Pembrokeshire</county>
<county>Radnorshire</county>
</country>
<country name="Northern Ireland">
<county>Antrim</county>
<county>Armagh</county>
<county>Down</county>
<county>Fermanagh</county>
<county>Londonderry</county>
<county>Tyrone</county>
</country>
</countries>
</xsl:variable>
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<label for="location"></label>
<select name="fields[location]" class="form-control" id="location">
<option>Select - Location</option>
<xsl:for-each select="exsl:node-set($uk-counties)/countries//county">
<option value="."><xsl:value-of select="."/></option>
</xsl:for-each>
</select>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment