// -*- c -*- // // $Id: xml_node_func.moc,v 1.5 2001/01/06 17:05:34 kmacleod Exp $ // static void node_tests(id, int); main () { id factory; printf ("1..18\n"); factory = XML_NonOpt_Document__new(NULL, 0); node_tests(factory, 0); factory = XML_FastSmall_Document__new(NULL, 0); node_tests(factory, 9); return 0; } static void node_tests(id factory, int testnum) { id doc, el, contents, attr, attrs; // [I2:1] Create a Document with an Element between PIs or Comments, // verify that doc.Root is the one Element doc = @factory.createDocument(); contents = @doc.contents; @contents.push(@factory.createComment()); el = @factory.createElement(); @contents.push(el); @contents.push(@factory.createProcessingInstruction()); ok(@doc.root == el, testnum + 1); // [I2:1] doc.Root is readonly // not testable in C yet, no exception handling // [I2:1] In Element, Name is made up of Prefix ":" LocalName, // changing any of Name, Prefix, or LocalName should be reflected in // the others. @el.name = @"Fu:Bar"; ok(strcmp(String_s(@el.prefix), "Fu") == 0, testnum + 2); ok(strcmp(String_s(@el.local_name), "Bar") == 0, testnum + 3); @el.prefix = @"Bravo"; ok(strcmp(String_s(@el.name), "Bravo:Bar") == 0, testnum + 4); @el.local_name = @"Charlie"; ok(strcmp(String_s(@el.name), "Bravo:Charlie") == 0, testnum + 5); // [12:1] In Attribute, Name is made up of Prefix ":" LocalName, // changing any of Name, Prefix, or LocalName should be reflected in // the others. attr = @factory.createAttribute(); @attr.name = @"Fu:Bar"; ok(strcmp(String_s(@attr.prefix), "Fu") == 0, testnum + 6); ok(strcmp(String_s(@attr.local_name), "Bar") == 0, testnum + 7); @attr.prefix = @"Bravo"; ok(strcmp(String_s(@attr.name), "Bravo:Bar") == 0, testnum + 8); @attr.local_name = @"Charlie"; ok(strcmp(String_s(@attr.name), "Bravo:Charlie") == 0, testnum + 9); // [I2:1] Creating nodes should accept a list of Property => Value // pairs // // Not implemented in C // [I2:2] el.Attributes['Foo'] is el.Attributes[(None, 'Foo')] // // C syntax has no (None, 'Foo') and no tuple class yet // [I2:2] el.Attributes['Fu:Bar'] is el.Attributes[('FuURI', 'Bar')], // iff el.Attributes[('FuURI', 'Bar')]['Prefix'] is 'Fu' // // C syntax has no string prefix indexing // [I2:2] an Attribute with a namespace but without a defined Prefix // is not accessible via a string index // // C syntax has no string prefix indexing // [I2:2] len(el.Attributes) is the number of attributes, not // indexes -- {a:uri}Beta, {an:uri}Foo, Bravo:Charlie, {z:uri}Zap // // C syntax has no string prefix indexing // [I2:2] keys(el.Attributes) returns Name for elements without a // NamespaceURI, and a (URI, LocalName) tuple for those with // // C impl has no keys() }