<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:wp="http://wordpress.org/export/1.2/"
    >
<!-- atom: http://www.ietf.org/rfc/rfc4287 -->
<!-- 
        WordPress Backup File XML to HTML via XSLT.
        (c) December 2013
        by Wyrd Smythe <TheWyrdSmythe@gmail.com>
        Granted to the public domain for non-commercial use.
        This work is release "as is" for your own use.
 -->
<xsl:output method="xml" encoding="UTF-8"/>

<!-- MAIN TEMPLATE -->
<xsl:template match="/rss">
<xsl:variable name="records" select="channel/item[wp:status='publish' and (wp:post_type='page' or wp:post_type='post')]" />
<xsl:message>Smythe's XSLT Program: wp-posts-pgdb</xsl:message>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:processing-instruction name="xml-stylesheet">href="pgdb.xsl" type="text/xsl"</xsl:processing-instruction>
<xsl:text>&#13;&#10;</xsl:text>
<xsl:element name="Document">
    <xsl:attribute name="type">index</xsl:attribute>
    <xsl:attribute name="name">wp-posts-pgdb</xsl:attribute>
    <xsl:attribute name="template-date">Fri Nov 11 21:00:00 2016</xsl:attribute>
    <xsl:attribute name="template-author">TheWyrdSymthe@gmail.com</xsl:attribute>
    <xsl:text>&#13;&#10;</xsl:text>
    <xsl:comment>
        <xsl:text>This file is automatically generated. Do not edit!</xsl:text>
    </xsl:comment>
    <xsl:text>&#13;&#10;</xsl:text>

    <!-- HEAD -->
    <xsl:element name="PropertyList">
        <xsl:attribute name="id">100</xsl:attribute>
        <xsl:text>&#13;&#10;</xsl:text>

        <xsl:element name="Property">
            <xsl:attribute name="name">dbname</xsl:attribute>
            <xsl:attribute name="value"><xsl:value-of select="channel/title"/></xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <xsl:element name="Property">
            <xsl:attribute name="name">description</xsl:attribute>
            <xsl:attribute name="value"><xsl:value-of select="channel/description"/></xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <xsl:element name="Property">
            <xsl:attribute name="name">foo</xsl:attribute>
            <xsl:attribute name="value">bar</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
    </xsl:element><!-- /PropertyList -->
    <xsl:text>&#13;&#10;</xsl:text>

    <!-- BODY -->
    <xsl:element name="Index">
        <xsl:attribute name="id">1000</xsl:attribute>
        <xsl:text>&#13;&#10;</xsl:text>

        <!-- Field Headers -->
        <xsl:call-template name="headers" />

        <!-- Field Data -->
        <xsl:element name="Records">
            <xsl:attribute name="id">1200</xsl:attribute>
            <xsl:attribute name="count"><xsl:value-of select="count($records)"/></xsl:attribute>
            <xsl:text>&#13;&#10;</xsl:text>
            <xsl:apply-templates select="$records" mode="post">
                <xsl:sort select="wp:post_date" data-type="text" order="ascending" />
            </xsl:apply-templates>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>

    </xsl:element><!-- /BODY -->
    <xsl:text>&#13;&#10;</xsl:text>

    <!-- Attachments -->
    <xsl:element name="Attachments">
        <xsl:attribute name="id">5000</xsl:attribute>
        <xsl:text>&#13;&#10;</xsl:text>
        <xsl:element name="Entry">
            <xsl:attribute name="id">5001</xsl:attribute>
            <xsl:attribute name="name">Thumbnail</xsl:attribute>
            <xsl:attribute name="type">image/png</xsl:attribute>
            <xsl:attribute name="urn"></xsl:attribute>
            <xsl:text>#</xsl:text>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <xsl:element name="Entry">
            <xsl:attribute name="id">5002</xsl:attribute>
            <xsl:attribute name="name">Logo</xsl:attribute>
            <xsl:attribute name="type">image/png</xsl:attribute>
            <xsl:attribute name="urn"></xsl:attribute>
            <xsl:text>#</xsl:text>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
    </xsl:element>
    <xsl:text>&#13;&#10;</xsl:text>

</xsl:element><!-- /Document -->
<xsl:text>&#13;&#10;</xsl:text>
<xsl:comment>
    <xsl:text>eof</xsl:text>
</xsl:comment>
<xsl:text>&#13;&#10;</xsl:text>
</xsl:template>


<!-- FIELD HEADERS TEMPLATE -->
<xsl:template name="headers">
    <xsl:element name="Fields">
        <xsl:attribute name="id">1100</xsl:attribute>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- PID -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1101</xsl:attribute>
            <xsl:attribute name="fid">pid</xsl:attribute>
            <xsl:attribute name="name">PID</xsl:attribute>
            <xsl:attribute name="type">integer</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Post Name -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1102</xsl:attribute>
            <xsl:attribute name="fid">name</xsl:attribute>
            <xsl:attribute name="name">Post Title</xsl:attribute>
            <xsl:attribute name="type">string</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Post Link -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1103</xsl:attribute>
            <xsl:attribute name="fid">url</xsl:attribute>
            <xsl:attribute name="name">Blog Link</xsl:attribute>
            <xsl:attribute name="type">url</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Post Date -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1104</xsl:attribute>
            <xsl:attribute name="fid">date</xsl:attribute>
            <xsl:attribute name="name">Publish Date</xsl:attribute>
            <xsl:attribute name="type">datetime/local</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Comment Count -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1105</xsl:attribute>
            <xsl:attribute name="fid">cmnts_nmbr</xsl:attribute>
            <xsl:attribute name="name"># Comments</xsl:attribute>
            <xsl:attribute name="type">integer</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Comment Status -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1106</xsl:attribute>
            <xsl:attribute name="fid">cmnts_stat</xsl:attribute>
            <xsl:attribute name="name">Comment Status</xsl:attribute>
            <xsl:attribute name="type">select/string</xsl:attribute>
            <xsl:text>open|closed</xsl:text>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Menu Order -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1104</xsl:attribute>
            <xsl:attribute name="fid">order</xsl:attribute>
            <xsl:attribute name="name">Menu Order</xsl:attribute>
            <xsl:attribute name="type">number</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Parent -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1104</xsl:attribute>
            <xsl:attribute name="fid">parent</xsl:attribute>
            <xsl:attribute name="name">Parent</xsl:attribute>
            <xsl:attribute name="type">number/pid</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Categories -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1107</xsl:attribute>
            <xsl:attribute name="fid">cats</xsl:attribute>
            <xsl:attribute name="name">Category</xsl:attribute>
            <xsl:attribute name="type">list/string</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Tags -->
        <xsl:element name="Field">
            <xsl:attribute name="id">1108</xsl:attribute>
            <xsl:attribute name="fid">tags</xsl:attribute>
            <xsl:attribute name="name">Tags</xsl:attribute>
            <xsl:attribute name="type">list/string</xsl:attribute>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
    </xsl:element>
    <xsl:text>&#13;&#10;</xsl:text>
</xsl:template>

<!-- POSTS TEMPLATE -->
<xsl:template match="item" mode="post">
    <!-- Record -->
    <xsl:element name="Record">
        <xsl:attribute name="rid"><xsl:value-of select="position()"/></xsl:attribute>
        <xsl:text>&#13;&#10;</xsl:text>

        <!-- PID -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">pid</xsl:attribute>
            <xsl:attribute name="post-type"><xsl:value-of select="wp:post_type"/></xsl:attribute>
            <xsl:value-of select="wp:post_id"/>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Post Title -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">name</xsl:attribute>
            <xsl:attribute name="post-name"><xsl:value-of select="wp:post_name"/></xsl:attribute>
            <xsl:value-of select="title"/>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Post Link -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">url</xsl:attribute>
            <xsl:value-of select="link"/>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Post Date -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">date</xsl:attribute>
            <xsl:value-of select="wp:post_date"/>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Comment Count -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">cmnts_nmbr</xsl:attribute>
            <xsl:value-of select="count(wp:comment)"/>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Comment Status -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">cmnts_stat</xsl:attribute>
            <xsl:value-of select="wp:comment_status"/>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Menu Order -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">order</xsl:attribute>
            <xsl:value-of select="wp:menu_order"/>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Parent -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">parent</xsl:attribute>
            <xsl:value-of select="wp:post_parent"/>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Categories -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">cats</xsl:attribute>
            <xsl:text>&#13;&#10;</xsl:text>
            <!-- Category List -->
            <xsl:apply-templates select="category[@domain='category']">
                <xsl:sort select="@nicename" data-type="text" order="ascending" />
            </xsl:apply-templates>
        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
        <!-- Tags -->
        <xsl:element name="Field">
            <xsl:attribute name="fid">tags</xsl:attribute>
            <xsl:text>&#13;&#10;</xsl:text>
            <!-- Tag List -->
            <xsl:apply-templates select="category[@domain='post_tag']">
                <xsl:sort select="@nicename" data-type="text" order="ascending" />
            </xsl:apply-templates>

        </xsl:element>
        <xsl:text>&#13;&#10;</xsl:text>
    </xsl:element>
    <xsl:text>&#13;&#10;</xsl:text>
</xsl:template>


<!-- CATEGORIES and TAGS TEMPLATE -->
<xsl:template match="category">
    <xsl:element name="Item">
        <xsl:attribute name="name"><xsl:value-of select="@nicename"/></xsl:attribute>
        <xsl:value-of select="text()"/>
    </xsl:element>
    <xsl:text>&#13;&#10;</xsl:text>
</xsl:template>


</xsl:stylesheet>

<!-- eof -->
