geuerp 2003/05/23 00:52:28
Modified: src/org/apache/xml/security/c14n/implementations
CanonicalizerBase.java
src/org/apache/xml/security/utils XMLUtils.java
Log:
Patch from dims; see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19916
Revision Changes Path
1.4 +2 -4
xml-security/src/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java
Index: CanonicalizerBase.java
===================================================================
RCS file:
/home/cvs/xml-security/src/org/apache/xml/security/c14n/implementations/CanonicalizerBase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CanonicalizerBase.java 11 Feb 2003 16:02:48 -0000 1.3
+++ CanonicalizerBase.java 23 May 2003 07:52:26 -0000 1.4
@@ -364,9 +364,7 @@
}
if (this._doc == null) {
- Node n = (Node) this._xpathNodeSet.iterator().next();
-
- this._doc = XMLUtils.getOwnerDocument(n);
+ this._doc = XMLUtils.getOwnerDocument(this._xpathNodeSet);
this._documentElement = this._doc.getDocumentElement();
this._rootNodeOfC14n = this._doc;
}
1.33 +29 -0
xml-security/src/org/apache/xml/security/utils/XMLUtils.java
Index: XMLUtils.java
===================================================================
RCS file:
/home/cvs/xml-security/src/org/apache/xml/security/utils/XMLUtils.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- XMLUtils.java 1 May 2003 18:20:25 -0000 1.32
+++ XMLUtils.java 23 May 2003 07:52:28 -0000 1.33
@@ -1000,6 +1000,35 @@
}
}
+ /**
+ * This method returns the first non-null owner document of the Node's
in this Set.
+ * This method is necessary because it <I>always</I> returns a
+ * [EMAIL PROTECTED] Document}. [EMAIL PROTECTED] Node#getOwnerDocument}
returns <CODE>null</CODE>
+ * if the [EMAIL PROTECTED] Node} is a [EMAIL PROTECTED] Document}.
+ *
+ * @param xpathNodeSet
+ * @return the owner document
+ */
+ public static Document getOwnerDocument(Set xpathNodeSet) {
+ NullPointerException npe = null;
+ Iterator iterator = xpathNodeSet.iterator();
+ while(iterator.hasNext()) {
+ Node node = (Node) iterator.next();
+ if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ return (Document) node;
+ } else {
+ try {
+ return node.getOwnerDocument();
+ } catch (NullPointerException e) {
+ npe = e;
+ }
+ }
+ }
+ throw new NullPointerException(I18n.translate("endorsed.jdk1.4.0")
+ + " Original message was \""
+ + (npe == null ? "" :
npe.getMessage()) + "\"");
+ }
+
/** Field randomNS */
private static String randomNS = null;