Last active
December 26, 2015 00:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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