[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: empty namespace added on elements E.g. <h4 xmln

Subject: RE: empty namespace added on elements E.g. <h4 xmlns="">
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 12 Jan 2010 13:07:41 -0000
RE:  empty namespace added on elements E.g.   <h4  xmln
> 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@xxxxxxxxxxxx]
> Sent: Tuesday, January 12, 2010 1:02 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  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 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.