views:

43

answers:

2
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"  
    version="1.0"  
    xmlns:ms="urn:schemas-microsoft-com:xslt" 
    xmlns:infoRequest="ControlSkin3" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
    exclude-result-prefixes="xmlns">

    <xsl:output omit-xml-declaration="yes" method="xml" encoding="utf-8" />

I've got a problem during the transformation in xhtml, some elements like this : xmlns:ms="urn:schemas-microsoft-com:xslt" are insered in a lot of my xhtml tag.

ex:

<script type="text/javascript" src="/style/js/etablissement/videos.js" 
    xmlns:infoRequest="ControlSkin3" 
    xmlns:ms="urn:schemas-microsoft-com:xslt" ></script>

I'm working on IIS6. and I've no explanations.

Did you have already the same problem? What's wrong about my code?

Thank you.

+2  A: 

You can exclude these namespaces by suppressing them via the exclude-result-prefixes attribute. You need to list the namespace prefixes separated by whitespace:

<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"  
    version="1.0"  
    xmlns:ms="urn:schemas-microsoft-com:xslt" 
    xmlns:infoRequest="ControlSkin3" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
    exclude-result-prefixes="infoRequest ms">
0xA3
@0xA3: I think that you need to refrase the first sentence as "You can exclude these namespaces **for literal result elements** ".
Alejandro
+4  A: 

exclude-result-prefixes="xmlns">

What's wrong about my code?

This isn't quite meaningful, as there isn't any namespace prefix in the XSLT stylesheet, named "xmlns".

On the other side, the existing prefixes are: "ms", "infoRequest" and "xsl".

If these prefixes are specified as a blank-separated list as the value of the exclude-result-prefixes attribute, then they will not be present in the serialization (output) of any literal result element.

For example:

<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
    version="1.0"
    xmlns:ms="urn:schemas-microsoft-com:xslt"
    xmlns:infoRequest="ControlSkin3"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="ms infoRequest xsl">

    <xsl:output omit-xml-declaration="yes" method="xml" encoding="utf-8" />

    <xsl:template match="/">
      <html>
        <head>
          <script type="text/javascript" src="/style/js/etablissement/videos.js">
            /* Script code here */
          </script>
        </head>
      </html>
    </xsl:template>
</xsl:stylesheet>

when this transformation is performed (on any source XML document -- not used), the result dosn't contain any unwanted namespaces:

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
        <script type="text/javascript" src="/style/js/etablissement/videos.js">
            /* Script code here */
        </script>
    </head>
</html>
Dimitre Novatchev
Thank you it's perfect.
Christophe Debove