--- src/org/apache/xml/security/utils/IdResolver.java (revision 781353) +++ src/org/apache/xml/security/utils/IdResolver.java (working copy) @@ -219,7 +219,7 @@ } while (sibling==null && parentNode!=null) { sibling=parentNode.getNextSibling(); parentNode=parentNode.getParentNode(); - if (!(parentNode instanceof Element)) { + if (parentNode != null && Node.ELEMENT_NODE != parentNode.getNodeType()) { parentNode=null; } } --- src/org/apache/xml/security/Init.java (revision 781353) +++ src/org/apache/xml/security/Init.java (working copy) @@ -145,7 +145,7 @@ } } for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) { - if (!(el instanceof Element)) { + if (el == null || Node.ELEMENT_NODE != el.getNodeType()) { continue; } String tag=el.getLocalName(); --- src/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java (revision 781353) +++ src/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java (working copy) @@ -198,7 +198,7 @@ try { NameSpaceSymbTable ns=new NameSpaceSymbTable(); int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT; - if (rootNode instanceof Element) { + if (rootNode != null && Node.ELEMENT_NODE == rootNode.getNodeType()) { //Fills the nssymbtable with the definitions of the parent of the root subnode getParentNameSpaces((Element)rootNode,ns); nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT; @@ -327,8 +327,8 @@ if (parentNode==endnode) return; sibling=parentNode.getNextSibling(); - parentNode=parentNode.getParentNode(); - if (!(parentNode instanceof Element)) { + parentNode=parentNode.getParentNode(); + if (parentNode == null || Node.ELEMENT_NODE != parentNode.getNodeType()) { documentLevel=NODE_AFTER_DOCUMENT_ELEMENT; parentNode=null; } @@ -384,7 +384,7 @@ return; boolean currentNodeIsVisible = false; NameSpaceSymbTable ns=new NameSpaceSymbTable(); - if (currentNode instanceof Element) + if (currentNode != null && Node.ELEMENT_NODE == currentNode.getNodeType()) getParentNameSpaces((Element)currentNode,ns); Node sibling=null; Node parentNode=null; @@ -505,7 +505,7 @@ return; sibling=parentNode.getNextSibling(); parentNode=parentNode.getParentNode(); - if (!(parentNode instanceof Element)) { + if (parentNode == null || Node.ELEMENT_NODE != parentNode.getNodeType()) { parentNode=null; documentLevel=NODE_AFTER_DOCUMENT_ELEMENT; } @@ -587,7 +587,7 @@ final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) { List parents=new ArrayList(10); Node n1=el.getParentNode(); - if (!(n1 instanceof Element)) { + if (n1 == null || Node.ELEMENT_NODE != n1.getNodeType()) { return; } //Obtain all the parents of the elemnt @@ -595,7 +595,7 @@ while (parent!=null) { parents.add(parent); Node n=parent.getParentNode(); - if (!(n instanceof Element )) { + if (n == null || Node.ELEMENT_NODE != n.getNodeType()) { break; } parent=(Element)n; --- src/org/apache/xml/security/encryption/XMLCipher.java (revision 781353) +++ src/org/apache/xml/security/encryption/XMLCipher.java (working copy) @@ -1392,7 +1392,7 @@ // The de-serialiser returns a fragment whose children we need to // take on. - if (sourceParent instanceof Document) { + if (sourceParent != null && Node.DOCUMENT_NODE == sourceParent.getNodeType()) { // If this is a content decryption, this may have problems --- src/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java (revision 781353) +++ src/org/apache/xml/security/keys/keyresolver/implementations/RetrievalMethodResolver.java (working copy) @@ -279,7 +279,7 @@ Element e=null; while (it.hasNext()) { Node currentNode=(Node)it.next(); - if (currentNode instanceof Element) { + if (currentNode != null && Node.ELEMENT_NODE == currentNode.getNodeType()) { e=(Element)currentNode; break; } @@ -291,7 +291,7 @@ do { parents.add(e); Node n=e.getParentNode(); - if (!(n instanceof Element )) { + if (n == null || Node.ELEMENT_NODE != n.getNodeType()) { break; } e=(Element)n;