Subject: Re: [xsl] Problem copying xhtml elements from xml source From: Josh Canfield <joshcanfield@xxxxxxxxx> Date: Mon, 12 Jul 2004 19:23:00 -0700 |
They are correct, this is a problem with your stylesheet. IE must be much more forgiving when it comes th xhtml compliance. When you look at the output you are actually taking the copied elements out of the xhtml namespace with an empty xmlns attribute. It looks like the way to fix this is to do a variation of the identity transform, but creating the elements with xsl:element, and using local-name() to get the name of the element. see http://www.dpawson.co.uk/xsl/sect2/N5536.html#d6223e1750 *** Updated XSL **** <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" encoding="UTF-8" indent="yes"/> <xsl:output method="xml" encoding="iso-8859-1" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" /> <xsl:template match="/test-copy-of"> <html lang="en" xml:lang="en"> <head> <title>test-copy-of</title> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/> </head> <body> <div> <xsl:apply-templates select="*"/> </div> </body> </html> </xsl:template> <xsl:template match="*"> <xsl:element name="{local-name()}"> <!-- go process attributes and children --> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template> <xsl:template match="@*"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:template> </xsl:stylesheet> On Tue, 13 Jul 2004 00:39:12 +0200, cking <cking@xxxxxxxxxx> wrote: > Hello, > > I didn't get many replies, maybe because I didn't include the code, > only the link to my testcase. So here's my question again: > is this a correct way to copy xhtml elements from an xml source file? > > ** source xml: > > <?xml version="1.0" encoding="iso-8859-1"?> > <?xml-stylesheet type="text/xsl" href="test-copy-of.xsl"?> > <test-copy-of> > <p style="color:red;">a paragraph in <b>red</b></p> > <p><img src="wood102.jpg" width="149" height="177" alt="wood"/></p> > </test-copy-of> > > ** test-copy-of.xsl: > > <xsl:stylesheet > version="1.0" > xmlns="http://www.w3.org/1999/xhtml" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > > > > <xsl:output > method="xml" > encoding="iso-8859-1" > indent="yes" > doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" > doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > /> > > <xsl:template match="/test-copy-of"> > <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> > <head> > <title>test-copy-of</title> > <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/> > </head> > <body> > <div> > <xsl:copy-of select="*"/> > </div> > </body> > </html> > </xsl:template> > > </xsl:stylesheet> > > This works as expected in IE6 and Saxon, but in Mozilla/Firefox, > all formatting is lost (as if only text nodes come through). > > The Mozilla folks say that the error is in the stylesheet. The reason > would be, that the elements from the source file are not in the > xhtml namespace. Is that true? And if yes, how can I make this work? > > Full testcase at http://users.telenet.be/cking/webstuff/test/copy-of/info.html > Bugreport: http://bugzilla.mozilla.org/show_bug.cgi?id=250921 > > Thanks for any help! > Anton Triest
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Problem copying xhtml element, cking | Thread | Re: [xsl] Problem copying xhtml ele, David Carlisle |
Re: [xsl] xpath dynamic selection, Josh Canfield | Date | Re: [xsl] determining the existence, Mukul Gandhi |
Month |