Re: xsl:copy-of working oddly?

Martin Honnen <[email protected]> Sun, 06 Apr 2008 12:33:57 +0200
Newsgroups gmane.comp.mozilla.devel.layout.xslt
Organization Liberty Development
Message-ID <[email protected]>
Daniel Cosuineau wrote:

> Using the web developer tool bar to view the generated source,
> everything looks as its supposed to (other than the paragraph tags
> being given xmlns="" attributes).

Does your XSLT stylesheet generate XHTML? Then you can't simply copy the 
  'p' element in your XML to the output as it is in no namespace and not 
in the XHTML namespace.
So you either need to fix the XML e.g.
<content>
   <p xmlns="http://www.w3.org/1999/xhtml">...</p>
</content>
or you need to change the stylesheet e.g.
   <xsl:apply-templates select="content/node()" mode="to-xhtml"/>

   <xsl:template match="*" mode="to-xhtml">
     <xsl:element name="{local-name()}" 
namespace="http://www.w3.org/1999/xhtml">
       <xsl:apply-templates select="@* | node()" mode="to-xhtml"/>
     </xsl:element>
   </xsl:template>

   <xsl:template match="@* | text()" mode="to-xhtml">
     <xsl:copy/>
   </xsl:template>



-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/