This commit is contained in:
Sean Mullan 2012-09-10 09:18:10 -04:00
commit 6ac22bda1f
5 changed files with 17 additions and 21 deletions

View File

@ -154,7 +154,7 @@ public final class Init {
} }
} }
for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) { for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
if (!(el instanceof Element)) { if (el.getNodeType() != Node.ELEMENT_NODE) {
continue; continue;
} }
String tag=el.getLocalName(); String tag=el.getLocalName();

View File

@ -205,7 +205,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
try { try {
NameSpaceSymbTable ns=new NameSpaceSymbTable(); NameSpaceSymbTable ns=new NameSpaceSymbTable();
int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT; int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
if (rootNode instanceof Element) { if (rootNode != null && rootNode.getNodeType() == Node.ELEMENT_NODE) {
//Fills the nssymbtable with the definitions of the parent of the root subnode //Fills the nssymbtable with the definitions of the parent of the root subnode
getParentNameSpaces((Element)rootNode,ns); getParentNameSpaces((Element)rootNode,ns);
nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT; nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
@ -335,7 +335,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
return; return;
sibling=parentNode.getNextSibling(); sibling=parentNode.getNextSibling();
parentNode=parentNode.getParentNode(); parentNode=parentNode.getParentNode();
if (!(parentNode instanceof Element)) { if (parentNode !=null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT; documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
parentNode=null; parentNode=null;
} }
@ -391,7 +391,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
return; return;
boolean currentNodeIsVisible = false; boolean currentNodeIsVisible = false;
NameSpaceSymbTable ns=new NameSpaceSymbTable(); NameSpaceSymbTable ns=new NameSpaceSymbTable();
if (currentNode instanceof Element) if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE)
getParentNameSpaces((Element)currentNode,ns); getParentNameSpaces((Element)currentNode,ns);
Node sibling=null; Node sibling=null;
Node parentNode=null; Node parentNode=null;
@ -512,7 +512,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
return; return;
sibling=parentNode.getNextSibling(); sibling=parentNode.getNextSibling();
parentNode=parentNode.getParentNode(); parentNode=parentNode.getParentNode();
if (!(parentNode instanceof Element)) { if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
parentNode=null; parentNode=null;
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT; documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
} }
@ -594,18 +594,14 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) { final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) {
List<Element> parents=new ArrayList<Element>(10); List<Element> parents=new ArrayList<Element>(10);
Node n1=el.getParentNode(); Node n1=el.getParentNode();
if (!(n1 instanceof Element)) { if (n1 == null || n1.getNodeType() != Node.ELEMENT_NODE) {
return; return;
} }
//Obtain all the parents of the elemnt //Obtain all the parents of the elemnt
Element parent=(Element) n1; Node parent = n1;
while (parent!=null) { while (parent!=null && parent.getNodeType() == Node.ELEMENT_NODE) {
parents.add(parent); parents.add((Element)parent);
Node n=parent.getParentNode(); parent = parent.getParentNode();
if (!(n instanceof Element )) {
break;
}
parent=(Element)n;
} }
//Visit them in reverse order. //Visit them in reverse order.
ListIterator<Element> it=parents.listIterator(parents.size()); ListIterator<Element> it=parents.listIterator(parents.size());

View File

@ -1445,7 +1445,7 @@ public class XMLCipher {
// The de-serialiser returns a fragment whose children we need to // The de-serialiser returns a fragment whose children we need to
// take on. // take on.
if (sourceParent instanceof Document) { if (sourceParent != null && sourceParent.getNodeType() == Node.DOCUMENT_NODE) {
// If this is a content decryption, this may have problems // If this is a content decryption, this may have problems

View File

@ -283,7 +283,7 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
Element e=null; Element e=null;
while (it.hasNext()) { while (it.hasNext()) {
Node currentNode=it.next(); Node currentNode=it.next();
if (currentNode instanceof Element) { if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE) {
e=(Element)currentNode; e=(Element)currentNode;
break; break;
} }
@ -292,14 +292,14 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
List<Element> parents=new ArrayList<Element>(10); List<Element> parents=new ArrayList<Element>(10);
//Obtain all the parents of the elemnt //Obtain all the parents of the elemnt
do { while (e != null) {
parents.add(e); parents.add(e);
Node n=e.getParentNode(); Node n=e.getParentNode();
if (!(n instanceof Element )) { if (n == null || n.getNodeType() != Node.ELEMENT_NODE) {
break; break;
} }
e=(Element)n; e=(Element)n;
} while (e!=null); }
//Visit them in reverse order. //Visit them in reverse order.
ListIterator<Element> it2=parents.listIterator(parents.size()-1); ListIterator<Element> it2=parents.listIterator(parents.size()-1);
Element ele=null; Element ele=null;

View File

@ -225,7 +225,7 @@ public class IdResolver {
} while (sibling==null && parentNode!=null) { } while (sibling==null && parentNode!=null) {
sibling=parentNode.getNextSibling(); sibling=parentNode.getNextSibling();
parentNode=parentNode.getParentNode(); parentNode=parentNode.getParentNode();
if (!(parentNode instanceof Element)) { if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
parentNode=null; parentNode=null;
} }
} }