I'm writing an XML serializer with JAXP. I'm receiving pseudo random data from a JAR and I'm building the DOM tree. I have to check if I already inserted the same Element into the tree; in order to perform this control I'm trying to use the method:
Element e = myDocument.getElementById(ao.getId());
if (e == null) {
// element is not a duplicate
access.appendChild(authorizationObject);
}else{
// element already in the tree
}
So, in every Element I create before adding them to the tree I set:
ao = a.getAuthorizationObject();
authorizationObject = myDocument.createElement("authorizationobject");
authorizationObject.setAttribute("id", ao.getId());
authorizationObject.setIdAttribute("id", true);
It can happen that in the object ao sometimes I get the same element twice (or more). The problem is that the program always enter inside the if instruction.
You can find all the program's code here and the DTD here for your reference.
What am I doing wrong? Thanks in advance for all your reply.