<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">

<xsl:key name="users.key"
         match="nathguil/wp_users"
         use="ID"/>

<xsl:key name="category.key"
         match="nathguil/wp_users"
         use="ID"/>

<xsl:key name="wp_term_taxonomy.key"
         match="nathguil/wp_term_taxonomy"
         use="term_taxonomy_id"/>

<xsl:key name="wp_terms.key"
         match="nathguil/wp_terms"
         use="term_id"/>

<xsl:template match="/">
	<xsl:apply-templates select="nathguil/wp_posts"/>
</xsl:template>

<xsl:template match="wp_comments">
	<xsl:variable name="id" select="comment_ID/text()"/>
	<xsl:message><xsl:value-of select="$id"/></xsl:message>
	<xsl:document href="comments/{$id}.html" method="html">
    <html><body>
		<xsl:value-of select="comment_content/text()"/>
	</body></html>
  </xsl:document>
</xsl:template>

<xsl:template match="wp_posts">
	<xsl:variable name="dir">
		<xsl:choose>
			<xsl:when test="post_type/text() = 'post'"><xsl:text>posts</xsl:text></xsl:when>
			<xsl:when test="post_type/text() = 'page'"><xsl:text>stories</xsl:text></xsl:when>
		</xsl:choose>
	</xsl:variable>
	<xsl:variable name="filename" select="post_name/text()"/>
	<xsl:variable name="author" select="post_author/text()"/>
	<xsl:variable name="id" select="ID/text()"/>
	<xsl:if test="post_type/text() = 'post' or post_type/text() = 'page'">
		<xsl:variable name="tags">
		<xsl:for-each select="//wp_term_relationships[object_id=$id]/term_taxonomy_id">
<!-- DEBUG
			<xsl:message><xsl:value-of select="$id"/>: <xsl:value-of select="."/></xsl:message>
			<xsl:message><xsl:value-of select="$id"/> term: <xsl:value-of select="key('wp_term_taxonomy.key',.)/term_id"/></xsl:message>
			<xsl:message><xsl:value-of select="$id"/> tag: <xsl:value-of select="key('wp_terms.key',key('wp_term_taxonomy.key',./text())/term_id)/name"/></xsl:message>
-->
			<xsl:value-of select="key('wp_terms.key',key('wp_term_taxonomy.key',./text())/term_id)/name"/><xsl:text>, </xsl:text>
		</xsl:for-each>
		</xsl:variable>
		<xsl:document href="{$dir}/{$filename}.html" method="html">
		<html>
			<head>
				<title><xsl:value-of select="post_title/text()"/></title>
			</head>
				<xsl:comment>title: <xsl:value-of select="post_title/text()"/></xsl:comment>
				<xsl:comment>slug: <xsl:value-of select="$filename"/></xsl:comment>
				<xsl:comment>date: <xsl:value-of select="post_date/text()"/></xsl:comment>
				<xsl:comment>author: <xsl:value-of select="key('users.key',$author)/display_name"/></xsl:comment>
				<xsl:comment>tags: <xsl:value-of select="$tags"/></xsl:comment>
			<body>
			<xsl:value-of disable-output-escaping="yes" select="post_content/text()"/>
		</body></html>
		</xsl:document>
		<xsl:document href="{$dir}/{$filename}.wordpress" method="text">
			<xsl:value-of disable-output-escaping="yes" select="post_content/text()"/>
		</xsl:document>
		<xsl:document href="{$dir}/{$filename}.meta" method="text">
			<xsl:text></xsl:text><xsl:value-of select="post_title/text()"/>
			<xsl:text>
</xsl:text><xsl:value-of select="$filename"/>
			<xsl:text>
</xsl:text><xsl:value-of select="post_date/text()"/>
			<xsl:text>
</xsl:text><xsl:value-of select="$tags"/>
			<xsl:text>
</xsl:text>
		</xsl:document>
	</xsl:if>
</xsl:template>

</xsl:stylesheet>

Source