Skip to content

Instantly share code, notes, and snippets.

@JohnNilsson
Created October 5, 2013 19:23
Show Gist options
  • Save JohnNilsson/6845089 to your computer and use it in GitHub Desktop.
Save JohnNilsson/6845089 to your computer and use it in GitHub Desktop.
XSLT to transform PList XML to something almost XML-like
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" />
<xsl:template match="/plist">
<xsl:element name="theme">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="dict">
<xsl:for-each select="key">
<xsl:element name="{text()}">
<xsl:apply-templates select="following-sibling::*[1]"/>
</xsl:element>
</xsl:for-each>
</xsl:template>
<xsl:template match="string">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="array">
<xsl:for-each select="dict">
<xsl:element name="setting">
<xsl:apply-templates select="current()"/>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment