Namespaces for Extensions
XSLT extension elements and extension functions must have a namespace prefix different from the XSLT namespace prefix. For example, here’s the start of a stylesheet that declares several namespace prefixes:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xalan-java="http://xml.apache.org/xslt/java"
xmlns:saxon-java="java:java.lang.Math"
extension-element-prefixes="xalan-java saxon-java">
By default, the XSLT processor copies all of the non-XSLT
namespaces to the output document. That means the svg
, xalan-java
, and saxon-java
namespaces will be defined in the
output. In this example, we’re generating an SVG document using
extensions associated with the xalan-java
and saxon-java
namespaces. We don’t need our
extension namespaces defined in the output document, so we use the
extension-element-prefixes
attribute to make sure they aren’t in the generated document. The
svg
namespace, on the other hand, will
appear in the output document, which is exactly what we
want.
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.