Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between exclude-result-prefixes and extension-element-prefix in XSLT namespace declaration?

What's the difference between exclude-result-prefixes and extension-element-prefix? Both are used in the header of XSLTs. I've found extension-element-prefix while using EXSLT and the EXSLT website Howto says that extension-element-prefix is used for "prevent the extension namespaces from being output in the result tree".

But this is not true (using libxslt). Only exclude-result-prefixes removes the extension namespace. So why do I need extension-element-prefix ???

Sample:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exsl="http://exslt.org/common" version="1.0"
  extension-element-prefix="exsl">

<xsl:template match="/">
  <blabla/>
</xsl:template>

</xsl:stylesheet>

My output with libxslt (xsltproc):

<?xml version="1.0"?>
<blabla xmlns:exsl="http://exslt.org/common"/>
like image 520
therealmarv Avatar asked Jul 13 '11 11:07

therealmarv


People also ask

What is exclude result prefixes in XSLT?

The exclude-result-prefixes attribute in both XSLT 1.0 and XSLT 2.0 allows for the exclusion of certain namespace declarations in the output document.

What is extension element prefixes?

The extension-element-prefix attribute simply signals that any elements with that prefix are not literals result elements but rather extension instructions in addition to those instructions defined by the XSLT language.

How to declare namespace in XSLT?

You'll usually find a namespace declaration in a document element's start-tag, and the XSLT processor passes this declaration along to the start-tag of the result document's document element. It also passes all references to that namespace along to the result tree, making the result document a working XLink document.

What is the extension XSLT?

xslt extension is an Extensible Stylesheet Language Transformation file that is used to transform and style an XML file using XSL instructions. The format is used to transform XML documents into standard output formats such as a text document or . html web page.


1 Answers

To use EXSLT functions like the one in the namespace http://exslt.org/common you don't need the extension-element-prefix attribute. That is only need if you want to use extension elements like func:function in the namespace http://exslt.org/functions. The extension-element-prefix attribute simply signals that any elements with that prefix are not literals result elements but rather extension instructions in addition to those instructions defined by the XSLT language.

As for exclude-result-prefixes, you have understood that right, it helps avoiding any namespace declarations on your result elements for namespaces declared and used in the stylesheet solely to select nodes in path expressions or match patterns or used to insert extension elements.

like image 82
Martin Honnen Avatar answered Oct 05 '22 21:10

Martin Honnen