views:

413

answers:

3

I have an XML document that I'm displaying in a web browser, with a stylesheet attached:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/css" href="abc.css"?>
<myxml xmlns:xhtml="http://www.w3.org/1999/xhtml"&gt;
    <para>I wish i was editable</para>
    <xhtml:script type="text/javascript" src="abc.js"/>
</myxml>

With the xhtml namespace declaration, and xhtml:script tag, I can execute javascript.

What I'd like to do is to make arbitrary non-XHTML elements in this document content editable. (Actually, they'll be in another namespace)

Even if I explicitly add @contentEditable="true" (ie without resorting to Javascript), the content is not actually editable (in Firefox 3.0.4).

Is it possible to edit it in any of the current browsers? (I had no problems with <div contentEditable="true">Edit me</div> in an XHTML 1.0 Transitional doc)

I can't even edit an xhtml:div in this document (in Firefox); if I could do that, that may offer a way forward.

A: 

contentEditable works (tested in Firefox and Chrome) on elements which are foreign to html/xhtml if I use this doctype:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      "http://www.w3.org/TR/html4/loose.dtd"&gt;

and a .html file extension (instead of .xml).

I don't have to include any html elements at all (eg head, body, div, p).

css isn't applied though (if my xml is in a namespace, which i guess makes sense, given the doctype!).

Not an elegant solution.

plutext
+1  A: 

In Firefox 3, @content-editable="true" only makes the relevant element editable if the content type is text/html (which also happens if a local filename ends with .html)

It doesn't work for content types app/xhtml+xml or text/xml (local filenames ending with .xhtml or .xml)

I've logged an enhancement for this: https://bugzilla.mozilla.org/show_bug.cgi?id=486931

plutext
A: 

Firefox is one of the few browsers that strictly enforces the XHTML spec. So, to make an element editable, you must specify the contenteditable attribute as true. Note that the whole attribute name is lower case. In your example the first "E" in editable was capitalized.

Another quirk that should be mentioned is that IE(6,7,8) act exactly the opposite. To make an element editable in IE, you MUST add contentEditable="true" exactly. For what ever reason, contenteditable="true" (as well as any other variation in capitalization) does not work.

Xavi