Filter XML elements by their namespace using XSLT

XSL Transformations (XSLT) is a powerful tool that can do much chore for us developers. Occasionally, XSLTs can compete with the other tools intended to transform XML. Look, for example, at the snippet that follows:
<xsl:template match="o:*" />
It strips out all the elements that are defined in the namespace referenced by alias o.

Explanation

A normal template expression has a format similar to the one of below:
<xsl:template match="author-group">
  <xsl:apply-templates select="author" />
</xsl:template>
This example processes all the author children of the author-group. By default, the XSLT processor processes each matched element only once. After an author-group element is selected, the processor outputs the author children of the matched element to XML. So, if the xsl:apply-templates element is omitted, the children of the source element are skipped during the transformation.

Comments

Popular posts from this blog

CREATE DATABASE (SMO)

Enable JSON serialization in your Visual Studio 2010 project

jQuery | remove inline style