Saturday, April 28, 2012

Blocking Namespace Declarations in XSLT Transformation Results


Suppose you want to block a namespace declaration from appearing in your XSLT transformation results; for example, suppose you have the namespace declaration of a function/element extension. You'd have to use the exclude-result-prefixes attribute in the stylesheet element. The value of this attribute is a list of prefixes separated by spaces.
Here's an example: 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"  
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
  xmlns:mc="http://www.airwings.org/register/"
  xmlns:informatii="http://www.airwings.org/info/"
  xmlns:FR="myPrefix://just.for.fun/java.io.FileReader"
  xmlns:BR="xalan://java.io.BufferedReader"
  exclude-result-prefixes="FR BR">

In the above example, the myPrefix://just.for.fun/java.io.FileReader and xalan://java.io.BufferedReader declarations will not be copied.

No comments:

Post a Comment