Last active
December 9, 2020 11:14
-
-
Save tts/4977062 to your computer and use it in GitHub Desktop.
Transform a WordPress export XML file to HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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