Sunday, August 15, 2010

Viewing the Items as HTML using XSLT

The items.xml only contains the itemnames and not the displayed names insided the game. For example cow_shamrock is displayed as "Kelly Green Cow". And for some items, we wanted to know which picture is behind, or the other way round, which code is belonging to an item we have seen in Farmville.

We wrote a simple XSL File to transform and filter out the items we need and display the pictures.
A sample output from the Transformation with a filter for decorations without limits.
First of all, how can we get the pictures. We started a Network sniffer and looked into the traffic and saw much request to http://static-2.farmville.com/v36206/ so we took this address to and appended the path from the items.xml. The path could change, so looked into the traffic with tools like wireshark to get the new path for the new images.

We documented the Code,if you have Questions just write a comment and we can update the explanation. The code should be useable for everyone even if you don't now anything about XSL.

The example code below sets a filter for all "buyable" items. Later it checks IF the item is limited, if NOT it displays the data.


Download the file from here.

We used SAXON Java version to perform this XSLT transformation.
Usage:
java -cp saxon9he.jar net.sf.saxon.Transform -o output.html items.xml transform.xsl
 If you open the output.html, you should see an output like the first image in this post. 

No comments:

Post a Comment