Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

version only

  • Loading branch information...
commit a3b013dab1b574cc4467bbe59257c0fa6457aae8 1 parent ddfd6fd
@jindw authored
View
5 package.json
@@ -1,6 +1,6 @@
{
"name": "xmldom",
- "version": "0.1.10",
+ "version": "0.1.11",
"description": "A W3C Standard XML DOM(Level2 CORE) implementation and parser(DOMParser/XMLSerializer).",
"keywords": ["XML","DOM","parser","javascript","DOMParser","XMLSerializer"],
"author": "jindw <jindw@xidea.org> (http://www.xidea.org)",
@@ -14,7 +14,8 @@
"maintainers": [{"name": "jindw","email": "jindw@xidea.org","url": "http://www.xidea.org"}],
"contributors": [
{"name" : "Yaron Naveh","email" : "yaronn01@gmail.com","web" : "http://webservices20.blogspot.com/"},
- {"name" : "Harutyun Amirjanyan","email" : "amirjanyan@gmail.com","web" : "https://github.com/nightwing"}
+ {"name" : "Harutyun Amirjanyan","email" : "amirjanyan@gmail.com","web" : "https://github.com/nightwing"},
+ {"name" : "bigeasy","email" : "alan@prettyrobots.com","web" : "http://www.prettyrobots.com/"}
],
"bugs": {"email": "jindw@xidea.org","url": "http://github.com/jindw/xmldom/issues"},
"licenses": [{"type": "LGPL","url": "http://www.gnu.org/licenses/lgpl.html"}]
View
51 test/big-file-performance.js
@@ -46,6 +46,22 @@ function domjs(data){
}
return doc
}
+function addAttributes(el){
+ var c =parseInt(Math.random()*10);
+ while(c--){
+ el.setAttribute('dynamic-attr'+c,c+new Array(c).join('.'));
+ }
+ var child = el.firstChild;
+ while(child){
+ if(child.nodeType == 1){
+ addAttributes(child)
+ }else if(child.nodeType == 4){//cdata
+ el.insertBefore(el.ownerDocument.createTextNode(child.data),child);
+ el.removeChild(child);
+ }
+ child = child.nextSibling;
+ }
+}
// Create a Test Suite
wows.describe('XML Node Parse').addBatch({
"big file parse":function(){
@@ -59,18 +75,39 @@ wows.describe('XML Node Parse').addBatch({
var doc3 = libxml(data);
- xmldomresult = (doc1+'').replace(/^<\?.*?\?>\s*|<!\[CDATA\[\]\]>/g,'')
+
+ addAttributes(doc1.documentElement);
+
+ data = doc1.toString();
+
+ var doc1 = xmldom(data);
+ var doc2 = domjs(data);
+ var doc3 = libxml(data);
+
+ xmldomresult = (domjs(doc1+'')+'').replace(/^<\?.*?\?>\s*|<!\[CDATA\[\]\]>/g,'')
domjsresult = (doc2+'').replace(/^<\?.*?\?>\s*|<!\[CDATA\[\]\]>/g,'')
-// var begin = 0;
-// var end = 5
-// xmldomresult = xmldomresult.substring(begin,end)
-// domjsresult = domjsresult.substring(begin,end)
-// console.log(xmldomresult,domjsresult)
+ //console.log(xmldomresult,domjsresult)
//assert.equal(xmldomresult,domjsresult);
//,xmldomresult,domjsresult)
- console.assert(xmldomresult == domjsresult,xmldomresult,domjsresult)
+ if(xmldomresult !== domjsresult){
+ for(var i=0;i<xmldomresult.length;i++){
+ if(xmldomresult.charAt(i)!=domjsresult.charAt(i)){
+ console.log(xmldomresult.charAt(i))
+ var begin = i-50;
+ var len = 100;
+ xmldomresult = xmldomresult.substr(begin,len)
+ domjsresult = domjsresult.substr(begin,len)
+ //console.log(xmldomresult.length,domjsresult.length)
+ console.log('pos'+i,'\n',xmldomresult,'\n\n\n\n',domjsresult)
+ console.assert(xmldomresult == domjsresult)
+ break;
+ }
+ }
+
+ }
+ //console.assert(xmldomresult == domjsresult,xmldomresult.length,i)
}
}).run(); // Run it
View
5 test/index.js
@@ -28,7 +28,10 @@ function check(data,doc){
xmldomresult = xmldomresult.replace(/^<\?.*?\?>\s*|<!\[CDATA\[\]\]>/g,'')
domjsresult = domjsresult.replace(/^<\?.*?\?>\s*|<!\[CDATA\[\]\]>/g,'')
//console.log('['+xmldomresult+'],['+domjsresult+']')
- assert.equal(xmldomresult,domjsresult);
+ if(xmldomresult!=domjsresult){
+ assert.equal(format(xmldomresult),domjsresult);
+ }
+
}
DOMParser.prototype.parseFromString = function(data,mimeType){
var doc = oldParser.apply(this,arguments);
View
2  test/namespace.js
@@ -13,7 +13,7 @@ wows.describe('XML Namespace Parse').addBatch({
console.assert(root.firstChild.getAttributeNode('attr').namespaceURI==null)
},
'prefix namespace': function () {
- var dom = new DOMParser().parseFromString('<xml xmlns:p1="http://p1.com" xmlns:p2="http://p2.com"><p1:child p1:attr="1"/><p2:child/></xml>','text/xml');
+ var dom = new DOMParser().parseFromString('<xml xmlns:p1="http://p1.com" xmlns:p2="http://p2.com"><p1:child a="1" p1:attr="1" b="2"/><p2:child/></xml>','text/xml');
var root = dom.documentElement;
console.assert(root.firstChild.namespaceURI == 'http://p1.com')
console.assert(root.lookupNamespaceURI('p1') == 'http://p1.com')
Please sign in to comment.
Something went wrong with that request. Please try again.