|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- |
| 3 | + This XSL transforms the Windows Timezone list from the Unicode CLDR to a plist |
| 4 | + which is consumable by CoreFoundation. You need to fetch the lastest mapping |
| 5 | + from the Unicode consortium from: |
| 6 | + https://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml |
| 7 | + The XSL can be applied to this data via the `xsltproc` command. |
| 8 | + Running |
| 9 | + `xsltproc ‐‐novalid OlsonWindowsDatabase.xsl windowsZones.xml` |
| 10 | + will generate the mapping plist. |
| 11 | +--> |
| 12 | +<xsl:stylesheet version="1.0" |
| 13 | + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 14 | + xmlns:ext="http://exslt.org/common" |
| 15 | + exclude-result-prefixes="ext"> |
| 16 | + <xsl:output encoding="utf-8" indent="yes" /> |
| 17 | + |
| 18 | + <xsl:template name="tokenize"> |
| 19 | + <xsl:param name="string" /> |
| 20 | + <xsl:param name="delimiter" /> |
| 21 | + |
| 22 | + <xsl:choose> |
| 23 | + <xsl:when test="not($string)"><items><item/></items></xsl:when> |
| 24 | + <xsl:when test="not(contains($string, $delimiter))" ><items><item><xsl:value-of select="$string" /></item></items></xsl:when> |
| 25 | + <xsl:otherwise><items><item><xsl:value-of select="normalize-space(substring-before($string, $delimiter))" /></item><xsl:call-template name="tokenize"> |
| 26 | + <xsl:with-param name="string" select="substring-after($string, $delimiter)" /> |
| 27 | + <xsl:with-param name="delimiter" select="$delimiter" /> |
| 28 | +</xsl:call-template></items> |
| 29 | + </xsl:otherwise> |
| 30 | + </xsl:choose> |
| 31 | + </xsl:template> |
| 32 | + |
| 33 | + <xsl:template match="/"> |
| 34 | + <xsl:text disable-output-escaping="yes"><!DOCTYPE plist SYSTEM "file:///localhost/System/Library/DTDs/PropertyList.dtd"> |
| 35 | +</xsl:text> |
| 36 | +<plist version="1.0"> |
| 37 | + <dict> |
| 38 | + <xsl:for-each select="supplementalData/windowsZones/mapTimezones/mapZone[not(@territory='001')]"> |
| 39 | +<xsl:variable name="names"> |
| 40 | + <xsl:call-template name="tokenize"> |
| 41 | + <xsl:with-param name="string" select="@type" /> |
| 42 | + <xsl:with-param name="delimiter" select="' '" /> |
| 43 | + </xsl:call-template> |
| 44 | +</xsl:variable> |
| 45 | + <key><xsl:value-of select="ext:node-set($names)/items/*" /></key> |
| 46 | + <string><xsl:value-of select="@other" /></string> |
| 47 | + </xsl:for-each> |
| 48 | + </dict> |
| 49 | +</plist> |
| 50 | + </xsl:template> |
| 51 | +</xsl:stylesheet> |
0 commit comments