Zander’s Weblog

Brief notes to myself about movies, books, and ‘stuff’

MySpaceToWordPress.xslt

leave a comment »

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:x="url:myspace"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:wp="http://wordpress.org/export/1.0/"
    xmlns:user="urn:user-namespace-here"
    exclude-result-prefixes="msxsl x"
>
  <!-- START JavaScript Functions -->
  <msxsl:script language="JScript" implements-prefix="user">
    <![CDATA[ 
 var itemcount=3;
 function GetItemCount()
 {
  itemcount++;
    return itemcount;
 } 
 ]]>
  </msxsl:script>
  <!-- END JavaScript functions -->
  <xsl:output method="xml" version="1.0" encoding="UTF-8" omit-xml-declaration="no" indent="yes" />
    <xsl:template match="x:items">
<rss version="2.0"
 xmlns:content="http://purl.org/rss/1.0/modules/content/"
 xmlns:wfw="http://wellformedweb.org/CommentAPI/"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:wp="http://wordpress.org/export/1.0/">
        <channel>
          <title>Zander's Weblog</title>
          <link>http://zanderxo.wordpress.com</link>
          <description>Just another WordPress.com weblog</description>
          <pubDate>Thu, 03 May 2008 05:56:18 +0000</pubDate>
          <generator>http://wordpress.org/?v=MU</generator>
          <language>en</language>
          <wp:wxr_version>1.0</wp:wxr_version>
          <wp:base_site_url>http://wordpress.com/</wp:base_site_url>
          <wp:base_blog_url>http://zanderxo.wordpress.com</wp:base_blog_url>
          <wp:category>
            <wp:category_nicename>books</wp:category_nicename>
            <wp:category_parent></wp:category_parent>
            <wp:cat_name><![CDATA[Books]]></wp:cat_name>
            <wp:category_description><![CDATA[Brief notes on books I have read.]]></wp:category_description>
          </wp:category>
          <wp:category>
            <wp:category_nicename>movies</wp:category_nicename>
            <wp:category_parent></wp:category_parent>
            <wp:cat_name><![CDATA[Movies]]></wp:cat_name>
            <wp:category_description><![CDATA[Brief notes on movies I have seen. Netflix just keeps on sending them!]]></wp:category_description>
          </wp:category>
          <wp:category>
            <wp:category_nicename>uncategorized</wp:category_nicename>
            <wp:category_parent></wp:category_parent>
            <wp:cat_name><![CDATA[Uncategorized]]></wp:cat_name>
          </wp:category>        
          <xsl:for-each select="x:item">
            <xsl:variable name="postName">
              <xsl:value-of select="translate(x:title,' ABCDEFGHIJKLMNOPQRSTUVWXYZ()','-abcdefghijklmnopqrstuvwxyz')"/>
            </xsl:variable>
            <item>
              <title>
                <xsl:value-of select="x:title"/>
              </title>
              <link>http://importedblog/<xsl:value-of select="$postName"/>
            </link>
              <pubDate>Thu, 01 May 2008 05:54:19 +0000</pubDate>
              <dc:creator><![CDATA[zanderxo]]></dc:creator>
              
                <xsl:choose>
                  <xsl:when test="x:category='Movies' or x:category='movies'">
                    <category>
                    <![CDATA[Movies]]>
                    </category>
                    <category domain="category" nicename="movies"><![CDATA[Movies]]></category>
                  </xsl:when>
                  <xsl:when test="x:category='Books' or x:category='books'">
                    <category>
                    <![CDATA[Books]]>
                    </category>
                    <category domain="category" nicename="books"><![CDATA[Books]]></category>
                  </xsl:when>
                  <xsl:otherwise>
                    <category>
                    <![CDATA[Uncategorized]]>
                    </category>
                    <category domain="category" nicename="uncategorized"><![CDATA[Uncategorized]]></category>
                  </xsl:otherwise>
                </xsl:choose>
              <xsl:variable name="itemCt">
                <xsl:value-of select="user:GetItemCount()"/>
              </xsl:variable>
              <guid isPermaLink="false">http://zanderxo.wordpress.com/?p=<xsl:value-of select="$itemCt"/></guid>
              <description></description>
              <content:encoded>
                <![CDATA[<p class="blogSubject"><span style="font-size:medium;font-family:Verdana, Arial, Helvetica, sans-serif;">]]><xsl:value-of select="x:content"/><![CDATA[</span></p>]]></content:encoded>
              <wp:post_id>
                <xsl:value-of select="$itemCt"/>
              </wp:post_id>
              <wp:post_date>2008-04-30 22:54:19</wp:post_date>
              <wp:post_date_gmt>2008-05-01 05:54:19</wp:post_date_gmt>
              <wp:comment_status>open</wp:comment_status>
              <wp:ping_status>open</wp:ping_status>
              <wp:post_name>
                <xsl:value-of select="$postName"/>
              </wp:post_name>
              <wp:status>publish</wp:status>
              <wp:post_parent>0</wp:post_parent>
              <wp:menu_order>0</wp:menu_order>
              <wp:post_type>post</wp:post_type>
              <wp:post_password></wp:post_password>
              <!--
              <wp:postmeta>             
                <wp:meta_key>_edit_lock</wp:meta_key>
                <wp:meta_value>1209621380</wp:meta_value>
              </wp:postmeta>
              <wp:postmeta>
                <wp:meta_key>_edit_last</wp:meta_key>
                <wp:meta_value>3860259</wp:meta_value>
              </wp:postmeta>
              -->
              <wp:postmeta>
                <wp:meta_key></wp:meta_key>
                <wp:meta_value></wp:meta_value>
              </wp:postmeta>
              <wp:postmeta>
                <wp:meta_key></wp:meta_key>
                <wp:meta_value></wp:meta_value>
              </wp:postmeta>
            </item>
          </xsl:for-each>
        </channel>
      </rss>
    </xsl:template>
</xsl:stylesheet>

Written by zanderxo

June 9, 2008 at 5:08 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.