anchor.diff:        assertTreeInvariants(xml);
         var actual = xml.toString();
         var expected =
  -          '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsd:lang="en">'
  -          '<xsd:element />'
  -          '</xsd:schema>';
  +      '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsd:lang="en">'
  +      '<xsd:element />'
  +      '</xsd:schema>';
  +      expect(actual, expected);
  +    });
  +    test('namespace binding optimized', () {
  +      var uri = 'http://www.w3.org/2001/XMLSchema';
  +      var builder = new XmlBuilder(optimizeNamespaces: true);
  +      builder.element('schema', nest: () {
  +        builder.namespace(uri, 'xsd');
  +        builder.attribute('lang', 'en', namespace: uri);
  +        builder.element('element', namespace: uri);
  +      }, namespace: uri);
  +      var xml = builder.build();
  +      assertTreeInvariants(xml);
  +      var actual = xml.toString();
  +      var expected =
  +      '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsd:lang="en">'
  +      '<xsd:element />'
  +      '</xsd:schema>';
         expect(actual, expected);
       });
       test('default namespace binding', () {
         var uri = 'http://www.w3.org/2001/XMLSchema';
  -      var builder = new XmlBuilder();
  +      var builder = new XmlBuilder(optimizeNamespaces: false);
         builder.element('schema', nest: () {
           builder.namespace(uri);
           builder.attribute('lang', 'en', namespace: uri);
  
positive.code:       var expected = '<foo:element xmlns:foo="http://1.foo.com/" />';
        expect(actual, expected);
      });
    });
    group('examples', () {
      test('books', () {
  
negative.code:       assertTreeInvariants(xml);
        var actual = xml.toString();
        var expected =
        '<schema xmlns="http://www.w3.org/2001/XMLSchema" lang="en">'
        '<element />'
        '</schema>';
        expect(actual, expected);
      });
      test('default namespace binding optimized', () {
        var uri = 'http://www.w3.org/2001/XMLSchema';
        var builder = new XmlBuilder(optimizeNamespaces: true);
        builder.element('schema', nest: () {
          builder.namespace(uri);
          builder.attribute('lang', 'en', namespace: uri);
          builder.element('element', namespace: uri);
        }, namespace: uri);
        var xml = builder.build();
        assertTreeInvariants(xml);
        var actual = xml.toString();
        var expected =
        '<schema xmlns="http://www.w3.org/2001/XMLSchema" lang="en">'
        '<element />'
        '</schema>';
        expect(actual, expected);
      });
      test('undefined namespace', () {
        var builder = new XmlBuilder(optimizeNamespaces: false);
        expect(() => builder.element('element', namespace: 'http://1.foo.com/'),
            throwsArgumentError);
      });
      test('undefined namespace optimized', () {
        var builder = new XmlBuilder(optimizeNamespaces: true);
        expect(() => builder.element('element', namespace: 'http://1.foo.com/'),
            throwsArgumentError);
      });
      test('invalid namespace', () {
        var builder = new XmlBuilder(optimizeNamespaces: false);
        builder.element('element', nest: () {
          expect(() => builder.namespace('http://1.foo.com/', 'xml'),
              throwsArgumentError);
  