Skip to content

Instantly share code, notes, and snippets.

@tts tts/gist:4977062
Last active Jan 7, 2018

Embed
What would you like to do?
Transform a WordPress export XML file to HTML
<!--
First export blog posts from WordPress, and then transform the exported XML file to HTML
with e.g. Saxon
java -jar saxon9.jar wordpress.2013-02-17.xml wp2html.xsl >wp.html
Tuija Sonkkila, 17.2.2013
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:excerpt="http://wordpress.org/export/1.0/excerpt/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.0/"
exclude-result-prefixes="content excerpt wfw dc wp"
version="2.0">
<xsl:output method="html" indent="yes" include-content-type="no"/>
<xsl:template match="/">
<html>
<head><title>Blog posts</title></head>
<body>
<xsl:apply-templates select="//item[wp:post_type='post'][wp:status='publish']/content:encoded"/>
</body>
</html>
</xsl:template>
<xsl:template match="content:encoded">
<h1><xsl:value-of select="../title"/></h1>
<p><em><xsl:value-of select="substring-before(../wp:post_date, ' ')"/></em></p>
<xsl:value-of select="text()" disable-output-escaping="yes"/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.