Re: [xsl] CDATA or escape in the result tree problems

Subject: Re: [xsl] CDATA or escape in the result tree problems
From: Abel Braaksma <>
Date: Wed, 01 Nov 2006 00:02:27 +0100
Kjetil Kjernsmo wrote:
The textarea element is in the default namespace of the stylesheet, I have not assigned any namespace to that.
you mean that your xpatch declaration is in the default namespace, your source document, or the textarea element in the source document? The xpath namespace must match the namespace of the textarea in the source document. Perhaps you can provide us with a smallest working example (with your error in it) with source/xslt/output?

The fragment I get from TinyMCE is asserted to be XHTML under some conditions I think I have met, but I have not actually seen a namespace on these elements either.

If there's no namespace attached in the source, then you can use it without namespace declarations in your XSLT.

I suspect "valid XHTML" ignores a few things, such as the namespace

If you mean what browsers do with it: indeed, they ignore the namespace declaration.

declaration. Also, TinyMCE gives me a whole document, but I manipulate the DOM in my application to only include children of the body.

But what is the part that eventually gets to the XSLT processor? A bunch of nodes surely must have a root node. Do you give the DOM to the XSLT processor? Does the DOM that you create have a namespace?

I tried to insert a xmlns:xhtml=""; and xhtml:textarea, but it made no difference.

In the source, the xpath or the xslt root declaration? If this is your XHTML:
<html xmlns="";>
<head><title>some title</title></head>
<textarea>Some data</textarea>

And this is your XSLT:
<xsl:stylesheet xmlns:xsl="";

<xsl:template match="/">
<xsl:apply-template select="xhtml:textarea" />
<xsl:template match="xhtml:textarea">
               Do something with this node

Then your output will look like this:
<textarea xmlns:xsl="";
   Do something with this node

Note that the output has no namespace attached for the textarea element. But the input document has and the XSLT document has (for the xhtml prefix, that is), and the XPath has.

-- Abel Braaksma

Current Thread