Menu

#63 namespaces lost

v 2.7
closed-invalid
None
5
2013-10-21
2011-07-19
No

Appearently, namespace declarations are handled in V2.2 but actually the namespace declarations get lost for the serializers. One reason is that xmlns namespace declaration are not added to the attributes anymore, the other is that TagNodes are copied sometimes but without the namespace declarations.

Fixes have to be done in the TagNode class:

TagNode makeCopy() {
TagNode copy = new TagNode(name);
copy.attributes.putAll(attributes);
// new:
if (nsDeclarations != null) {
copy.nsDeclarations = new TreeMap(nsDeclarations);
}
return copy;
}

public void setAttribute(String attName, String attValue) {
if ( attName != null && !"".equals(attName.trim()) ) {
attName = attName.toLowerCase();
if ("xmlns".equals(attName)) {
addNamespaceDeclaration("", attValue);
} else if (attName.startsWith("xmlns:")) {
addNamespaceDeclaration( attName.substring(6), attValue );
}
// this adds the xmlns attributes to the attributes
// else {
attributes.put(attName, attValue == null ? "" : attValue );
// }
}
}

Keeping the namespace declarations is absolutely essential e.g. for web pages with RDFa metadata and other newer metadata standards for HTML.

Discussion

  • Scott Wilson

    Scott Wilson - 2013-05-18
    • assigned_to: Scott Wilson
    • Group: --> v 2.6
     
  • Scott Wilson

    Scott Wilson - 2013-05-18

    Thanks Walter, I'll take a look at this issue for v 2.6

     
  • Scott Wilson

    Scott Wilson - 2013-08-03
    • Group: v 2.6 --> v 2.7
     
  • Scott Wilson

    Scott Wilson - 2013-10-03

    Hi Walter,

    I've checked in several test cases for retaining namespace declarations, and namespace prefixes on both elements and attributes. Everything seems to be OK - can you test with the latest version and see if this problem has already been fixed? If not if you can supply a test case I'll investigate further.

     
  • Scott Wilson

    Scott Wilson - 2013-10-21
    • status: open --> closed-invalid
     
  • Scott Wilson

    Scott Wilson - 2013-10-21

    Marking as closed-invalid (seems to have been fixed in an earlier release)

     

Log in to post a comment.