<commit_before>// +----------------------------------------------------------------------+
// | Bitflux Editor                                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 Bitflux GmbH                                      |
// +----------------------------------------------------------------------+
// | This software is published under the terms of the Apache Software    |
// | License a copy of which has been included with this distribution in  |
// | the LICENSE file and is available through the web at                 |
// | http://bitflux.ch/editor/license.html                                |
// +----------------------------------------------------------------------+
// | Author: <NAME> <<EMAIL>>                        |
// +----------------------------------------------------------------------+
//
// $Id: ElementVAL.js,v 1.15 2004/01/15 08:24:48 chregu Exp $


XMLNodeElement.prototype.__defineGetter__(
"allowedChildren", function() {
	
	// everything which isn't an Element, can't have children
	if (typeof this._allowedChildren == "undefined") {
		var ctxt = new ContextVDOM(this,this.vdom);
		var ac = new Array();
		var subac = null;
		try{
			if (ctxt.vdom ) {
				do {
					subac = ctxt.vdom.allowedElements(ctxt);
					
					if (subac && subac.nodeName) {
						ac.push(subac);
					} else if (subac) {
						for (var i = 0; i < subac.length; i++) {
							ac.push(subac[i]);
						}
					}
				} while (ctxt.nextVDOM())
			}
			ac.sort(bxe_nodeSort);

			this._allowedChildren = ac;
			return ac;
		} catch(e){
			debug("end with catch get allowed Children for " + this.nodeName);
			bxe_catch_alert(e);
			return ac;
		} 
	} else { 
		return this._allowedChildren;
	}
}
)

XMLNodeElement.prototype.__defineGetter__(
"allowedNextSiblings", function() {
		// everything which isn't an Element, can't have children
	if (typeof this._allowedNextSiblings == "undefined") {
		var ctxt = new ContextVDOM(this.parentNode,this.parentNode.vdom);
		var ac = new Array();
		var subac = null;
		
		
		try{
			if (ctxt.vdom ) {
			
				do {
					
					subac = ctxt.vdom.allowedElements(ctxt);
					
					if (subac && subac.nodeName) {
						if (subac[i].localName != "#text") {
							var bla =  new XMLNodeElement(subac.namespaceURI, subac.localName, 1);
							this.parentNode.insertBeforeIntern(bla,this.nextSibling);
							if( bla.parentNode.isNodeValid(false,2,true)) {
								ac.push(subac);
							}
							bla.unlink();
							bla=null;
						}
						
					} else if (subac) {
						for (var i = 0; i < subac.length; i++) {
							if (subac[i].localName != "#text") {
								var bla =  new XMLNodeElement(subac[i].namespaceURI, subac[i].localName, 1);
								this.parentNode.insertBeforeIntern(bla,this.nextSibling);
								if( bla.parentNode.isNodeValid(false,2,true)) {
									ac.push(subac[i]);
								}
								bla.unlink();
								bla = null;
							}<commit_msg>more fixes for append bug<commit_after>// +----------------------------------------------------------------------+
// | Bitflux Editor                                                       |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003 Bitflux GmbH                                      |
// +----------------------------------------------------------------------+
// | This software is published under the terms of the Apache Software    |
// | License a copy of which has been included with this distribution in  |
// | the LICENSE file and is available through the web at                 |
// | http://bitflux.ch/editor/license.html                                |
// +----------------------------------------------------------------------+
// | Author: <NAME> <<EMAIL>>                        |
// +----------------------------------------------------------------------+
//
// $Id: ElementVAL.js,v 1.16 2004/01/15 10:19:40 chregu Exp $


XMLNodeElement.prototype.__defineGetter__(
"allowedChildren", function() {
	
	// everything which isn't an Element, can't have children
	if (typeof this._allowedChildren == "undefined") {
		var ctxt = new ContextVDOM(this,this.vdom);
		var ac = new Array();
		var subac = null;
		try{
			if (ctxt.vdom ) {
				do {
					subac = ctxt.vdom.allowedElements(ctxt);
					
					if (subac && subac.nodeName) {
						ac.push(subac);
					} else if (subac) {
						for (var i = 0; i < subac.length; i++) {
							ac.push(subac[i]);
						}
					}
				} while (ctxt.nextVDOM())
			}
			ac.sort(bxe_nodeSort);

			this._allowedChildren = ac;
			return ac;
		} catch(e){
			debug("end with catch get allowed Children for " + this.nodeName);
			bxe_catch_alert(e);
			return ac;
		} 
	} else { 
		return this._allowedChildren;
	}
}
)

XMLNodeElement.prototype.isValidNextSibling = function(ctxt) {
	if (!ctxt) {
		try {
			if (this.parentNode.vdom) {
				ctxt = new ContextVDOM(this.parentNode, this.parentNode.vdom);
			} else {
				dump(this.previousSibling.nodeName +" jjj \n");
				return false;
			}
	} catch (e) { bxe_catch_alert(e); debug ("couldn't make new context..");}
	}
	
	
	do {
		if (ctxt.node.nodeType == "3" && ctxt.node.isWhitespaceOnly) {
			continue;
		} 	
		if (ctxt.node.nodeType == Node.COMMENT_NODE) {
			continue;
		}
		//FIXME: check CDATA_SECTIONS AS WELL
		if (ctxt.node.nodeType == Node.CDATA_SECTION_NODE) {
			continue;
		}
		var _vdom = ctxt.vdom;
		if (  ctxt.isValid()) {
		} else {
			ctxt.isError = true;
		}
		if (ctxt.node == this) {
			break;
		}
	} while (ctxt.next() );
	
	return (!ctxt.isError);
	
}

XMLNodeElement.prototype.__defineGetter__(
"allowedNextSiblings", function() {
		// everything which isn't an Element, can't have children
	if (typeof this._allowedNextSiblings == "undefined") {
		var ctxt = new ContextVDOM(this.parentNode,this.parentNode.vdom);
		var ac = new Array();
		var subac = null;
		
		
		try{
			if (ctxt.vdom ) {
				do {
					
					subac = ctxt.vdom.allowedElements(ctxt);
					if (subac && subac.nodeName) {
						if (subac[i].localName != "#text") {
							var bla =  new XMLNodeElement(subac.namespaceURI, subac.localName, 1);
							this.parentNode.insertBeforeIntern(bla,this.nextSibling);
							
							if(bla.isValidNextSibling() ) {
								ac.push(subac);
							}
							bla.unlink();
							bla=null;
						}
						
					} else if (subac) {
						for (var i = 0; i < subac.length; i++) {
							if (subac[i].localName != "#text") {
								var bla =  new XMLNodeElement(subac[i].namespaceURI, subac[i].localName, 1);
								
								this.parentNode.insertBeforeIntern(bla,this.nextSibling);
								
								if(bla.isValidNextSibling()  ) {
									ac.push(subac[i]);
								}
								bla.unlink();
								bla = null;
							}
{'fraction_non_alphanumeric': 0.2286850242968635, 'fraction_numerical': 0.007804447062288323, 'mean_word_length': 1.5678638941398866, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1420061', 'n_tokens_mistral': 2632, 'n_tokens_neox': 2050, 'n_words': 456}