#221 ElementSerializer remembers namespaces when reused

1.3.0 (final)
closed-fixed
Ernst de Haan
5
2006-02-20
2006-02-20
Ernst de Haan
No

The ElementSerializer class offers a serialize(Element)
method that returns a string with an XML document for
the specified XML element object. XML Namespaces are
supported.

When serialize is called twice for the same XML element
that contains at least one namespace declaration, then
the namespace declaration is not output during the
second serialization.

Reason is that the namespaces are remembered after the
first serialization attempt.

Very simple testcase that fails for XINS 1.3.0:

public void testElementSerializer() throws Exception {

// Build an element
ElementBuilder builder = new ElementBuilder("b",
"a");
builder.setAttribute("c", "2");
Element element = builder.createElement();

ElementSerializer serializer = new
ElementSerializer();

// Serialize it
String expected = "<ns0:a xmlns:ns0=\"b\" c=\"2\"/>";
String actual = serializer.serialize(element);
assertEquals(expected, actual);

// Repeat that
actual = serializer.serialize(element);
assertEquals(expected, actual);
}

Discussion

  • Ernst de Haan
    Ernst de Haan
    2006-02-20

    Logged In: YES
    user_id=11053

    Fixed. Will be in XINS 1.4.0-beta1.

     
  • Ernst de Haan
    Ernst de Haan
    2006-02-20

    • status: open --> closed-fixed