Skip to content

Instantly share code, notes, and snippets.

@Flackus
Created March 1, 2011 15:16
Show Gist options
  • Save Flackus/849272 to your computer and use it in GitHub Desktop.
Save Flackus/849272 to your computer and use it in GitHub Desktop.
Challenge 2.0
<![CDATA[<div class="post">
<p>Текст</p>
<div>
<div><span><b><i>]]><ya user="nop"></ya><![CDATA[</i></b></span></div>
</div>
</div>]]>
<div class="post">
<p>Текст</p>
<div>
<div>
<span>
<b>
<i>
<ya user="nop"/>
</i>
</b>
</span>
</div>
</div>
</div>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="div[@class='post']">
<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
<xsl:call-template name="identity"/>
<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
</xsl:template>
<xsl:template match="node() | @*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[starts-with(name(),'ya')]">
<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
<xsl:copy-of select="."/>
<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment