Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns="http://docbook.org/ns/docbook"
- >
- <xsl:strip-space elements="*"/>
- <xsl:output version="1.0" encoding="utf-8" indent="yes"/>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="/">
- <article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
- <xsl:apply-templates select="blog_post"/>
- </article>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="blog_post">
- <xsl:apply-templates select="head"/>
- <xsl:apply-templates select="body"/>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="head">
- <info>
- <title><xsl:value-of select="title"/></title>
- <author>
- <personname>
- <firstname><xsl:value-of select="author/name"/></firstname>
- <surname><xsl:value-of select="author/surname"/></surname>
- </personname>
- </author>
- <authorinitials>MR</authorinitials>
- <xsl:if test="tags/tag">
- <keywordset>
- <xsl:for-each select="tags/tag">
- <keyword><xsl:value-of select="."/></keyword>
- </xsl:for-each>
- </keywordset>
- </xsl:if>
- <xsl:if test="date">
- <date><xsl:value-of select="date"/></date>
- </xsl:if>
- </info>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="body">
- <xsl:for-each select="node()">
- <xsl:choose>
- <xsl:when test="name()='code'">
- <screen>
- <xsl:value-of select="."/>
- </screen>
- </xsl:when>
- <xsl:when test="name()='question' or name()='p' or name()='ul' or name()='img'">
- <xsl:apply-templates select="."/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="question">
- <p>
- <xsl:value-of select="body/text()"/>
- <xsl:text> [ </xsl:text>
- <xsl:value-of select="selectedanswer"/>
- <xsl:text> ] </xsl:text>
- </p>
- <xsl:apply-templates select="body/code"/>
- <xsl:apply-templates select="options"/>
- <p>
- <xsl:value-of select="answer"/>
- </p>
- <hr/>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="code">
- <screen>
- <xsl:value-of select="."/>
- </screen>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="img">
- <mediaobject>
- <imagedata></imagedata>
- </mediaobject>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="ul">
- <itemizedlist>
- <xsl:for-each select="./li">
- <listitem>
- <para>
- <xsl:value-of select="."/>
- </para>
- </listitem>
- </xsl:for-each>
- </itemizedlist>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="options">
- <ul>
- <xsl:for-each select="./option">
- <li>
- <xsl:number format="a. " />
- <xsl:value-of select="."/>
- </li>
- </xsl:for-each>
- </ul>
- </xsl:template>
- <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
- <xsl:template match="p">
- <para>
- <xsl:for-each select="node()">
- <xsl:choose>
- <xsl:when test="name() = 'em'">
- <emphasis><xsl:value-of select="."/></emphasis>
- </xsl:when>
- <xsl:when test="name() = 'var'">
- <literal><xsl:value-of select="."/></literal>
- </xsl:when>
- <xsl:when test="name() = 'ul'">
- <xsl:apply-templates select="."/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- </para>
- </xsl:template>
- </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment