Re: Patches

Christian Stocker <[email protected]> Fri, 19 Nov 2004 15:20:51 +0100
Newsgroups gmane.editors.bitflux.general
Message-ID <[email protected]>
Hi Niklas

Many thanks for your patches. I applied them to trunk and 1_0

Actually, problem 1 I fixed yesterday as well, but your code looks a 
little bit cleaner, so I took that one (and i forgot it to apply to the 
1_0 branch) now

Why ctxt.node._node in root nodes don't work is a different story, I 
have to look it up. maybe it's really a "bug", which should be changed 
some day...

Problem 2 was new to me. Also committed.

chregu



On 19.11.2004 14:59 Uhr, Niklas Therning wrote:
> 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
> 

-- 
christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich
phone +41 1 240 56 70 | mobile +41 76 561 88 60  | fax +41 1 240 56 71
http://www.bitflux.ch  |  [email protected]  |  gnupg-keyid 0x5CE1DECB
-- 
bx-editor-users mailing list
[email protected]
http://lists.bitflux.ch/cgi-bin/listinfo/bx-editor-users