In one of my recent WordProcessingML (Microsoft Word XML) XSLT projects I had to transform paragraphs with the cite style into blockquote, those with code style into pre and the rest of them into regular paragraphs. Instead of using a complex xsl:choose structure, I've defined three templates:
<xsl:template match="w:p[w:pPr/w:pStyle/@w:val = 'cite']">
<blockquote class="{w:pPr/w:pStyle/@w:val}">
<xsl:apply-templates />
</blockquote>
</xsl:template>
<xsl:template match="w:p[w:pPr/w:pStyle/@w:val = 'code']">
<pre class="{w:pPr/w:pStyle/@w:val}">
<xsl:apply-templates />
</pre>
</xsl:template>
<xsl:template match="w:p">
... regular code goes here ...
</xsl:template>
No comments:
Post a Comment