1169d9 | 2004-05-02 | Martin Nilsson | | START_MARKER
|
0d3929 | 2005-12-18 | Martin Nilsson | | // $Id: testsuite.in,v 1.7 2005/12/18 03:34:50 nilsson Exp $
|
408f9e | 2002-08-02 | Martin Nilsson | |
// DOM
// Tree
|
0d3929 | 2005-12-18 | Martin Nilsson | | define(test_tree_eq,[[
test_eq(Parser.XML.Tree.parse_input $1 ,$2)
test_eq(Parser.XML.Tree.simple_parse_input $1 ,$2)
test_eq(Parser.XML.Tree.Node $1 ,$2)
test_eq(Parser.XML.Tree.SimpleNode $1 ,$2)
]])
|
ccf77a | 2003-12-23 | Henrik Grubbström (Grubba) | | test_eval_error([[ Parser.XML.Tree.parse_input("<foo>", 0, 0, 0, 1); ]])
|
0d3929 | 2005-12-18 | Martin Nilsson | | test_tree_eq([[ ("<a>foo > hej &x.y; hopp < bar</a>")->render_xml() ]],
|
24443a | 2002-10-25 | Martin Nilsson | | [[ "<a>foo > hej &x.y; hopp < bar</a>" ]])
|
0d3929 | 2005-12-18 | Martin Nilsson | | test_tree_eq([[ ("<a>foo > hej &x.y; hopp < bar</a>")->render_xml(1); ]],
|
24443a | 2002-10-25 | Martin Nilsson | | [[ "<a>foo > hej &x.y; hopp < bar</a>" ]])
|
0d3929 | 2005-12-18 | Martin Nilsson | | test_tree_eq([[ ("<a>hej &x.y; hopp</a>")->render_xml(); ]],
|
24443a | 2002-10-25 | Martin Nilsson | | [[ "<a>hej &x.y; hopp</a>" ]])
|
0d3929 | 2005-12-18 | Martin Nilsson | | test_tree_eq([[ ("<a>hej &x.y; hopp</a>")->render_xml(1); ]],
|
24443a | 2002-10-25 | Martin Nilsson | | [[ "<a>hej &x.y; hopp</a>" ]])
test_eq([[ (string)Parser.XML.Tree.parse_input("<a><b> <c/> </b></a>") ]],
[[ "<a><b> <c/> </b></a>" ]])
|
0d3929 | 2005-12-18 | Martin Nilsson | | test_tree_eq([[ ("<p>a<![CDATA[b]""]>c</p>")[0][0]->get_text() ]],
|
f989a0 | 2005-10-31 | Martin Nilsson | | [[ "abc" ]])
|
0d3929 | 2005-12-18 | Martin Nilsson | | test_tree_eq([[ ("<?xml version=\"1.0\"?><!DOCTYPE greeting SYSTEM \"hello.dtd\"><!-- comment -- --><x/>")->render_xml() ]],
[[ "<?xml version='1.0' encoding='utf-8'?><!DOCTYPE greeting SYSTEM \"hello.dtd\"><!-- comment -- --><x/>" ]])
test_any([[
class A {
inherit Parser.XML.Tree.Node;
public array(this_program) mChildren = ({});
};
return sizeof(A("<!-- --><!-- --><x/>")->mChildren);
]], 3)
|
24443a | 2002-10-25 | Martin Nilsson | |
|
408f9e | 2002-08-02 | Martin Nilsson | | // NSTree
// XML NS section 2
test_any_equal([[
object x=Parser.XML.NSTree.parse_input(#"
<x>
<!-- No namespace here. -->
</x>");
x=x[0];
array r = ({});
r += ({ x->get_any_name() });
r += ({ x->get_default_ns() });
r += ({ x->get_ns() });
r += ({ x->get_defined_nss()->edi });
return r;
]], ({ "x", 0, 0, 0 }) )
test_any_equal([[
object x=Parser.XML.NSTree.parse_input(#"
<x xmlns:edi='http://ecommerce.org/schema'>
<!-- the 'edi' prefix is bound to http://ecommerce.org/schema
for the 'x' element and contents -->
</x>");
x=x[0];
array r = ({});
r += ({ x->get_any_name() });
r += ({ x->get_default_ns() });
r += ({ x->get_ns() });
r += ({ x->get_defined_nss()->edi });
r += ({ x[0]->get_default_ns() });
r += ({ x[0]->get_ns() });
r += ({ x[0]->get_defined_nss()->edi });
return r;
]], ({ "x", 0, 0, "http://ecommerce.org/schema",
0, 0, "http://ecommerce.org/schema" }) )
// XML NS section 4
test_any_equal([[
object x=Parser.XML.NSTree.parse_input(#"
<x xmlns:edi='http://ecommerce.org/schema'>
<!-- the 'price' element's namespace is http://ecommerce.org/schema -->
<edi:price units='Euro'>32.18</edi:price>
</x>");
x=x[0];
array r = ({});
r += ({ x[3]->get_any_name() });
r += ({ x[3]->get_ns() });
r += ({ x[3]->get_attributes()->units });
r += ({ x[3][0]->get_ns() });
return r;
]], ({ "price", "http://ecommerce.org/schema", "Euro", 0 }) );
test_any_equal([[
object x=Parser.XML.NSTree.parse_input(#"
<x xmlns:edi='http://ecommerce.org/schema'>
<!-- the 'taxClass' attribute's namespace is http://ecommerce.org/schema -->
<lineItem edi:taxClass=\"exempt\">Baby food</lineItem>
</x>");
x=x[0];
array r = ({});
r += ({ x[3]->get_ns() });
r += ({ x[3]->get_attributes() });
r += ({ x[3]->get_ns_attributes() });
return r;
]], ({ 0, ([]), ([ "http://ecommerce.org/schema":
([ "taxClass":"exempt" ]) ]) }) )
// XML NS section 5.1
test_any_equal([[
object x=Parser.XML.NSTree.parse_input(#"
<?xml version=\"1.0\"?>
<!-- all elements here are explicitly in the HTML namespace -->
<html:html xmlns:html='http://www.w3.org/TR/REC-html40'>
<html:head><html:title>Frobnostication</html:title></html:head>
<html:body><html:p>Moved to
<html:a href='http://frob.com'>here.</html:a></html:p></html:body>
</html:html>");
x=x[2];
array r = ({});
r += ({ x->get_ns() });
r += ({ x->get_default_ns() });
r += ({ x[0]->get_ns() });
r += ({ x[0]->get_default_ns() });
r += ({ x[3][0][1]->get_attributes()->href });
return r;
]], ({ "http://www.w3.org/TR/REC-html40", 0, 0, 0,
"http://frob.com" }) )
test_any_equal([[
object x=Parser.XML.NSTree.parse_input(#"
<?xml version=\"1.0\"?>
<!-- both namespace prefixes are available throughout -->
<bk:book xmlns:bk='urn:loc.gov:books'
xmlns:isbn='urn:ISBN:0-395-36341-6'>
<bk:title>Cheaper by the Dozen</bk:title>
<isbn:number>1568491379</isbn:number>
</bk:book>");
x=x[2];
array r = ({});
r += ({ x->get_ns() });
r += ({ x->get_defined_nss() });
r += ({ x[1]->get_ns() });
r += ({ x[3]->get_ns() });
return r;
]], ({ "urn:loc.gov:books", ([ "bk":"urn:loc.gov:books",
"isbn":"urn:ISBN:0-395-36341-6" ]),
"urn:loc.gov:books", "urn:ISBN:0-395-36341-6" }) )
// XML NS section 5.2
test_any_equal([[
object x=Parser.XML.NSTree.parse_input(#"
<?xml version=\"1.0\"?>
<!-- initially, the default namespace is \"books\" -->
<book xmlns='urn:loc.gov:books'
xmlns:isbn='urn:ISBN:0-395-36341-6'>
<title>Cheaper by the Dozen</title>
<isbn:number>1568491379</isbn:number>
<notes>
<!-- make HTML the default namespace for some commentary -->
<p xmlns='urn:w3-org-ns:HTML'>
This is a <i>funny</i> book!
</p>
</notes>
</book>");
x=x[2];
array r = ({});
r += ({ x->get_ns() });
r += ({ x->get_default_ns() });
r += ({ x->get_defined_nss() });
r += ({ x[1]->get_ns() });
r += ({ x[3]->get_ns() });
x=x[5];
r += ({ x[3]->get_ns() });
r += ({ x[3][1]->get_ns() });
r += ({ x[3][1]->get_default_ns() });
return r;
]], ({ "urn:loc.gov:books", "urn:loc.gov:books",
([ "isbn":"urn:ISBN:0-395-36341-6" ]),
"urn:loc.gov:books", "urn:ISBN:0-395-36341-6",
"urn:w3-org-ns:HTML", "urn:w3-org-ns:HTML",
"urn:w3-org-ns:HTML" }) )
// We don't test the case with empty namespace, since it
// it is unclear how we should behave.
// XML Section 5.3
test_any_equal([[
object x=Parser.XML.NSTree.parse_input(#"
<!-- http://www.w3.org is bound to n1 and is the default -->
<x xmlns:n1=\"http://www.w3.org\"
xmlns=\"http://www.w3.org\" >
<good a=\"1\" n1:a=\"2\" />
</x>");
x=x[1][1];
array r = ({});
r += ({ x->get_ns() });
r += ({ x->get_ns_attributes()[x->get_ns()] });
r += ({ x->get_attributes() });
return r;
]], ({ "http://www.w3.org", (["a":"2"]), (["a":"1"]) }) )
|
a6b02d | 2002-08-20 | Martin Nilsson | | // End of XML NS spec tests
test_do([[
array args = ({
"xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'",
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'",
"xmlns:xsd='http://www.w3.org/2001/XMLSchema'",
"xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'",
"soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'" });
for(int i; i<120; i++)
Parser.XML.NSTree.parse_input("<soap:Envelope "+Array.permute(args,i)*" "+"/>");
]])
|
408f9e | 2002-08-02 | Martin Nilsson | | // Simple
// Validating
|
1169d9 | 2004-05-02 | Martin Nilsson | | END_MARKER
|