Patches
Niklas Therning <[email protected]> Fri, 19 Nov 2004 14:59:22 +0100
| Newsgroups | gmane.editors.bitflux.general |
|---|---|
| Message-ID | <[email protected]> |
Since I started using BXE I have run into a few problems which I have
been able to solve on my own. I would like to contribute those patches
back to the project. I might have done stupid things here so don't be to
hard on me. At least the fixes seem to work for my setup. ;-)
Problem 1:
I have a custom element with a required attribute in my XML. The element
is outside of the editable area. BXE will complain that this attribute
is missing even if it's there.
To reproduce this edit the uni example. Add a required attribute to
<unizh:highlights> in unizh.rng.xml and make sure you set that attribute
on <unizh:highlights> in content.xml. Now if you edit the uni example in
BXE you should get an error message that a required attribute is missing
even though we just added it to content.xml.
My fix is to replace
AttributeVDOM.prototype.isValid = function(ctxt) {
if (ctxt.node._node && !this.optional &&
!ctxt.node._node.hasAttribute(this.name)) {
in relaxng/AttributeVDOM.js with
AttributeVDOM.prototype.isValid = function(ctxt) {
var o = null;
if (ctxt.node.xmlBridge) {
o = ctxt.node.xmlBridge;
} else if (ctxt.node._node) {
o = ctxt.node._node;
}
if (o != null && !this.optional && !o.hasAttribute(this.name)) {
It seems to work. Ask someone else why! ;-)
Problem 2:
In Firefox 1.0 I sometimes got a JS error: Error: [Exception... "An
attempt was made to create or change an object in a way which is
incorrect with regard to namespaces" code: "14" nsresult: "0x8053000e
(NS_ERROR_DOM_NAMESPACE_ERR)" location:
"file:///home/niklas/tmp/cms/bxe_stable/js/bxeNodeElements.js Line: 505"]
Source File: file:///home/niklas/tmp/cms/bxe_stable/js/bxeNodeElements.js
Line: 505
The setAttributeNS method doesn't like to set attributes which are in
the xmlns namespace. If something like:
<p xmlns:q="yada">...</p>
is in your XML you will get this error and BXE will freeze. I tried to
add a simple test which prevents any attributes which are in the xmlns
namespace to be set:
Change line 505 in js/bxeNodeElements.js to
if (attribs[i].namespaceURI != "http://www.w3.org/2000/xmlns/") {
_node.setAttributeNS(attribs[i].namespaceURI,
attribs[i].localName,attribs[i].value);
}
It seems to work for me.
I hope some of this will be useful.
/Niklas
--
bx-editor-users mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-users