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

17,410

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.

Share:
17,410

Related videos on Youtube

therealmarv
Author by

therealmarv

Software Engineer with passion for everything related to smart, open, standardized, mobile, cloud technology.

Updated on October 07, 2022

Comments

  • therealmarv
    therealmarv over 1 year

    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"/>
    
  • therealmarv
    therealmarv almost 13 years
    Ah ok. This makes sense. I just wondered why I should use extension-element-prefix because I could remove it completely with http://exslt.org/common. Seems the EXSLT documentation is wrong at this part.
  • therealmarv
    therealmarv almost 13 years
    or extension-element-prefix only hides elements from output tree which need extension-element-prefix. To be on the save path I will use extension-element-prefix and exclude-result-prefixes both at the same time when I use extension libraries like EXSLT.
  • Michael Kay
    Michael Kay almost 13 years
    Some people use extension-element-prefixes all the time when they only need exclude-result-prefixes, and it works, because EEP has two effects: it allows you to use the namespace for extension elements (a privilege you can ignore), and it adds the namespace to the ERP list.