My primary goal is to resize some of my background images appropriate to the the screen resolution for a specific mobile. So I filtered the resolution_width and resolution_height information.
Here is the small xslt code used to shrink the wurfl.xml .
<?xml version="1.0" ?>
<!--
This file part of MiniIM.
Copyright (C) 2007 Kamanashis Roy
MiniIM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MiniIM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MiniIM. If not, see <http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<!-- select the device tag -->
<xsl:template match="/wurfl">
<wurfl>
<xsl:copy-of select="version"/>
<devices>
<xsl:apply-templates select="devices/device"/>
</devices>
</wurfl>
</xsl:template>
<!-- process devices -->
<xsl:template match="device">
<device fall_back="{@fall_back}" id="{@id}" user_agent="{@user_agent}">
<!-- keep only display group -->
<xsl:apply-templates select="group[@id='display']"/>
</device>
</xsl:template>
<xsl:template match="group">
<!-- render non empty group -->
<xsl:if test="count(capability[@name='resolution_width'])=1">
<group id="{@id}">
<xsl:apply-templates select="capability[@name='resolution_width']"/>
<xsl:apply-templates select="capability[@name='resolution_height']"/>
</group>
</xsl:if>
</xsl:template>
<xsl:template match="capability">
<capability name="{@name}" value="{@value}"/>
</xsl:template>
</xsl:stylesheet>
Now let us do the transform, I have used xsltproc for the transform here, you may want to get xsltproc binary for your os or get source here. And you can apply transform like this,
shell> xsltproc your_shrinker.xslt wurfl.xml > wurfl_shrinked.xml
You can do some appropriate modifications to this code to keep some other attributes too. I prefer to write separate xsl code for each application. Note there are other alternatives, like database
usage available in wurfl site. So please read those docs before trying this :) .
Finally I used the cool perl module form imagemagick to resize my images :) .
Enjoy !
