xsl-list
[Top] [All Lists]

RE: [xsl] empty namespace added on elements E.g. <h4 xmlns="">

2010-01-12 07:08:46

Ok... so I made a little change to the last xslt (see below) 

A little change? You've made a gigantic change! Instead of creating elements
using literal result elements in the stylesheet, you are creating them by
copying from the source document. 

xsl:copy and xsl:copy-of copy the name of an element unchanged (that is,
both the local name and namespace). If you want to change either the local
name or the namespace, you can't use xsl:copy, you need to use xsl:element.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 


in my cocoon pipeline which adds the xhtml namespace on 
xsl:stylesheet level.

However, now the namespace is not added to the root tag  like 

<html xmlns="http://www.w3.org/1999/xhtml";>
 ...
</html>


I get
<html>
...
</html>

So validation still fails.  
--------------------------------------------------------------
----------
---------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Author: Robby Pelssers
  This stylesheet escapes all values within <escapeHtml> tag 
and should be used as last stylesheet in the
  transformation process right before final serialization to xhtml
-->

<xsl:stylesheet version="2.0" 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns="http://www.w3.org/1999/xhtml";>
  
  <xsl:output method="xml" version="1.0" encoding="UTF-8" 
indent="yes"/>
  
  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>
      
  <!-- copy all nodes and attributes which are not processed 
by one of available templates -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="escapeHtml">
    <xsl:value-of select="." disable-output-escaping="yes"/>
  </xsl:template>

</xsl:stylesheet>
--------------------------------------------------------------
----------
---------------------------------------------

-----Original Message-----
From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Sent: Tuesday, January 12, 2010 1:02 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] empty namespace added on elements E.g. <h4 
xmlns=""> 


You're creating an <html> element in the XHTML namespace, and then you
create an <h4> element in no namespace: to prevent the h4 
element going
into
the XHTML namespace, Saxon has to generate the xmlns="" 
declaration. If
you
want the h4 element to be in the XHTML namespace, which I 
guess you do,
then
say so by coding it as <h4 xmlns="http://www.w3.org/1999/xhtml";>.

(A literal result element is copied literally from the 
stylesheet to the
result document. There's no magic process whereby the namespace of the
element is changed to match that of its new parent.)

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--