﻿<xsl:stylesheet version="1.0" 
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<!-- lulalala	2008/10/16	created -->

<xsl:output method="text" encoding="UTF-8"/>

<xsl:variable name="categories" select="blog_backup/blog_articles_categories/category"/>
<xsl:variable name="comments" select="blog_backup/blog_articles_comments/article_comment"/>
<xsl:variable name="author" select="blog_backup/blog_blogs/id"/>

<xsl:template match="/"><xsl:apply-templates select="blog_backup"/></xsl:template>

<xsl:template match="blog_backup"><xsl:apply-templates select="blog_articles_m/article"/></xsl:template>

<xsl:template match="article">AUTHOR: <xsl:value-of select="userid"/>
TITLE: <xsl:value-of select="title"/>
DATE: <xsl:apply-templates select="date"/>
PRIMARY CATEGORY: <xsl:value-of select="$categories[id=current()/category_id]/name"/>
STATUS: <xsl:if test="isCloak=0">publish</xsl:if><xsl:if test="isCloak!=0">draft</xsl:if>
ALLOW COMMENTS: <xsl:value-of select="allow_comment"/>
-----
BODY:
<xsl:value-of select="text"/>
-----<xsl:apply-templates select="$comments[article_id=current()/id]"/><!--comments-->
--------
</xsl:template>
<!--ping: wretch 沒有-->

<xsl:template match="article_comment">
COMMENT:
AUTHOR: <xsl:value-of select="name"/>
<xsl:if test="string(email)">
EMAIL: <xsl:value-of select="email"/></xsl:if>
<xsl:if test="string(url)">
URL: <xsl:value-of select="url"/></xsl:if>
<!--無名把IP地址轉換成了無法理解的int <xsl:if test="ip">IP: <xsl:value-of select="ip"/></xsl:if>-->
DATE: <xsl:apply-templates select="date"/><xsl:text>
</xsl:text><xsl:value-of select="text"/>
-----<xsl:if test="string(reply)">
COMMENT:
AUTHOR: <xsl:value-of select="$author"/>
DATE: <xsl:apply-templates select="reply_date"/><xsl:text>
</xsl:text><xsl:value-of select="reply"/>
-----</xsl:if></xsl:template>

<xsl:template match="date|reply_date">
<xsl:value-of select="substring(.,6,2)"/>/<xsl:value-of select="substring(.,9,2)"/>/<xsl:value-of select="substring(.,1,4)"/><xsl:text> </xsl:text><xsl:value-of select="substring(.,12,8)"/>
</xsl:template>

</xsl:stylesheet>
