Subject: RE: [xsl] empty namespace added on elements E.g. <h4 xmlns=""> From: "Robby Pelssers" <robby.pelssers@xxxxxxxxx> Date: Tue, 12 Jan 2010 13:35:28 +0100 |
Ok... so I made a little change to the last xslt (see below) 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: [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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] empty namespace added on , Michael Kay | Thread | Re: [xsl] empty namespace added on , Martin Honnen |
Re: [xsl] Definite list of XSLT 2.0, Christoph LANGE | Date | Re: [xsl] empty namespace added on , Martin Honnen |
Month |