Category Archives: xml

Google Maps Redux

Welp, google has relased their Google Maps API. It’s VERY nice. The code to draw my runs has gone from about 230 lines, down to about 100. But logically, it’s MUCH better.

the only problem I’m hitting is this – before I was generating the polyline myself, so google just had to draw it. Now, however, there is a GPolyline object that draws lines for you – much easier to code for, MUCH slower.

I’m sure this is a solution, and I’ll post it here when I find it.

Source:

http://metaatem.net/my_runs.phps

Data:

http://metaatem.net/data_run.xml

–UPDATE–

Turns out I was mostly being dumb. If I had red the example source more closely, I would have seen you can put the points in an array and throw that to GPolyline… duh!
Cleaner, and faster, what more can you ask for?

XSL to transform iTunes play lists to html

It outputs tables, but it *is* tabular data :)

if I was stronger with xsl, it would be a bit cleaner, and allow you to supply the colors easily, but you get what you pay for.
To use it, File > Export Song List > Save as XML.
Then navigate to it on the form, and hit “upload”

Here is the form if you want to play with it (please be kind):
iTunes Playlist Transformer
Source Code

Here is just the XSL:

<?xml version="1.0" ?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
  
  <xsl:output method="html" />
  <xsl:template match="/">
        <table style='border-collpase:collapse; ' border='1'>
            <tr style='background-color:#ddd;'>
                <th colspan='4'>Playlist Name: <xsl:value-of select="plist/dict/key[text()='Playlists']/following-sibling::array/dict/string" /></th>
            </tr>
            <tr style='background-color:#ddd;'>
                <th>Artist</th>
                <th>Track Name</th>
                <th>Album</th>
                <th>Played</th>
            </tr>
        <xsl:for-each select="plist/dict/key[text()='Playlists']/following-sibling::array/dict/array/dict">
            <xsl:call-template name="track">
                <xsl:with-param name="trackid" select='integer' />
            </xsl:call-template>
        </xsl:for-each>
        </table>
    </xsl:template>
    <xsl:template name="track">
        <xsl:param name="trackid" />
        <xsl:variable name="thistrack" select="/plist/dict/key[text()='Tracks']/following-sibling::dict/key/following-sibling::dict/integer[text()=\$trackid]" />
        <tr>
            <xsl:choose>
                <xsl:when test="position() mod 2 = 1">
                    <xsl:attribute name="style">background-color: #bbb</xsl:attribute>
                </xsl:when>
                <xsl:otherwise> 
                    <xsl:attribute name="style">background-color: #999</xsl:attribute>
                </xsl:otherwise>
            </xsl:choose>
            
            <td><xsl:value-of select="\$thistrack/following-sibling::key[text()='Artist']/following-sibling::string" /></td>
            <td><xsl:value-of select="\$thistrack/following-sibling::key[text()='Name']/following-sibling::string" /></td>
            <td><xsl:value-of select="\$thistrack/following-sibling::key[text()='Album']/following-sibling::string" /></td>
            <td><xsl:value-of select="\$thistrack/following-sibling::key[text()='Play Count']/following-sibling::integer" /></td>
        </tr>
    </xsl:template>

</xsl:stylesheet>