Skip to content

Instantly share code, notes, and snippets.

@jmarshallnz
Last active December 26, 2015 00:39
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 jmarshallnz/7065945 to your computer and use it in GitHub Desktop.
Save jmarshallnz/7065945 to your computer and use it in GitHub Desktop.
Simple XSLT sheet for transforming XBMC XML pre-pull request https://github.com/xbmc/xbmc/pull/3451
#! /bin/sh
find 720p/ -name '*.xml' | while IFS=$'\n' read -r FILE; do
echo "processing: $FILE"
xsltproc -o temp.xml xbmc_label_pos.xslt "$FILE"
mv temp.xml "$FILE"
done
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" />
<!-- copy template -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- copy anything under layouts -->
<xsl:template match="itemlayout|focusedlayout">
<xsl:copy-of select="."/>
</xsl:template>
<!-- filter out all non-labels -->
<xsl:template match="control">
<xsl:copy>
<xsl:choose>
<xsl:when test="@type='label' and align='right'">
<xsl:for-each select="@*|node()">
<xsl:choose>
<xsl:when test="name()='posx'">
<right><xsl:value-of select="." /></right>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="@*|node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment