|
@@ -14,14 +14,14 @@ class TestXML extends Test {
|
|
|
var x = Xml.parse('<a href="hello">World<b/></a>');
|
|
|
|
|
|
t( x.firstChild() == x.firstChild() );
|
|
|
-
|
|
|
+
|
|
|
eq( x.nodeType, Xml.Document );
|
|
|
checkExc(x);
|
|
|
|
|
|
x = x.firstChild();
|
|
|
eq( x.nodeType, Xml.Element );
|
|
|
|
|
|
-
|
|
|
+
|
|
|
// nodeName
|
|
|
eq( x.nodeName, "a" );
|
|
|
x.nodeName = "b";
|
|
@@ -124,7 +124,7 @@ class TestXML extends Test {
|
|
|
|
|
|
eq( Xml.createCData("<x>").toString(), "<![CDATA[<x>]]>" );
|
|
|
eq( Xml.createComment("Hello").toString(), "<!--Hello-->" );
|
|
|
-
|
|
|
+
|
|
|
#if flash9
|
|
|
eq( Xml.createProcessingInstruction("XHTML").toString(), "<?XHTML ?>");
|
|
|
// doctype is parsed but not printed
|
|
@@ -133,7 +133,7 @@ class TestXML extends Test {
|
|
|
eq( Xml.createProcessingInstruction("XHTML").toString(), "<?XHTML?>");
|
|
|
eq( Xml.createDocType("XHTML").toString(), "<!DOCTYPE XHTML>" );
|
|
|
#end
|
|
|
-
|
|
|
+
|
|
|
eq( Xml.parse("<!--Hello-->").firstChild().nodeValue, "Hello" );
|
|
|
var c = Xml.createComment("Hello");
|
|
|
eq( c.nodeValue, "Hello" );
|
|
@@ -190,20 +190,20 @@ class TestXML extends Test {
|
|
|
exc(function() for (x in xml) null);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testEntities() {
|
|
|
var entities = ["<", ">", """, "&", "'", " ", "€", "@", "ô", "?", "ÿ"];
|
|
|
var values = entities.copy();
|
|
|
- #if (flash || js)
|
|
|
+ #if (flash || js || cs || java)
|
|
|
// flash parser does support XML + some HTML entities (nbsp only ?) + character codes entities
|
|
|
values = ['<', '>', '"', '&', "'", String.fromCharCode(160), '€', '@', 'ô', '?', 'ÿ'];
|
|
|
#end
|
|
|
-
|
|
|
+
|
|
|
#if flash9
|
|
|
// for a very strange reason, flash9 uses a non standard charcode for non breaking space
|
|
|
values[5] = String.fromCharCode(65440);
|
|
|
#end
|
|
|
-
|
|
|
+
|
|
|
#if php
|
|
|
// and € creates an invalid entity error (first time I see PHP being strict !)
|
|
|
entities[5] = "x";
|
|
@@ -211,33 +211,33 @@ class TestXML extends Test {
|
|
|
// character codes entities are supported
|
|
|
values = ["<", ">", """, "&", "'", "x", "x", '@', 'ô', '?', 'ÿ'];
|
|
|
#end
|
|
|
-
|
|
|
+
|
|
|
for( i in 0...entities.length ) {
|
|
|
infos(entities[i]);
|
|
|
eq( Xml.parse(entities[i]).firstChild().nodeValue, values[i] );
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testCustomXmlParser() {
|
|
|
var entities = ["<", ">", """, "&", "'", "€", "@", "ô", "?", "ÿ"];
|
|
|
var values = ['<', '>', '"', '&', "'", '€', '@', String.fromCharCode(244), String.fromCharCode(0x3F), String.fromCharCode(0xFF)];
|
|
|
-
|
|
|
- for( i in 0...entities.length ) {
|
|
|
+
|
|
|
+ for( i in 0...entities.length) {
|
|
|
infos(entities[i]);
|
|
|
eq( haxe.xml.Parser.parse(entities[i]).firstChild().nodeValue, values[i] );
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
var s = "<a>><b><</b><><b>><</b>\"</a>";
|
|
|
var xml = haxe.xml.Parser.parse(s);
|
|
|
eq(s, xml.toString());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function testMore() {
|
|
|
var doc = Xml.parse("<a>A</a><i>I</i>");
|
|
|
var aElement = doc.elementsNamed('a').next();
|
|
|
var iElement = doc.elementsNamed('i').next();
|
|
|
iElement.addChild(aElement);
|
|
|
-
|
|
|
+
|
|
|
eq(doc.toString(), "<i>I<a>A</a></i>");
|
|
|
}
|
|
|
-}
|
|
|
+}
|