You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by vd...@apache.org on 2004/02/12 19:13:22 UTC
cvs commit: xml-security/src/org/apache/xml/security/utils IdResolver.java
vdkoogh 2004/02/12 10:13:21
Modified: src/org/apache/xml/security/utils IdResolver.java
Log:
Remove Xerces dependency
PR: 26789
Submitted by: Ditmann Werner
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.15 +40 -9 xml-security/src/org/apache/xml/security/utils/IdResolver.java
Index: IdResolver.java
===================================================================
RCS file: /home/cvs/xml-security/src/org/apache/xml/security/utils/IdResolver.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- IdResolver.java 8 Feb 2004 06:11:51 -0000 1.14
+++ IdResolver.java 12 Feb 2004 18:13:21 -0000 1.15
@@ -25,6 +25,8 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import java.util.WeakHashMap;
+
/**
* Purpose of this class is to enable the XML Parser to keep track of ID
@@ -47,6 +49,8 @@
static org.apache.commons.logging.Log log =
org.apache.commons.logging.LogFactory.getLog(IdResolver.class.getName());
+ static WeakHashMap docMap = new WeakHashMap();
+
/**
* Constructor IdResolver
*
@@ -63,11 +67,13 @@
* @param idValue
*/
public static void registerElementById(Element element, String idValue) {
-
Document doc = element.getOwnerDocument();
-
- ((org.apache.xerces.dom.DocumentImpl) doc).putIdentifier(idValue,
- element);
+ WeakHashMap elementMap = (WeakHashMap) docMap.get(doc);
+ if(elementMap == null) {
+ elementMap = new WeakHashMap();
+ docMap.put(doc, elementMap);
+ }
+ elementMap.put(idValue, element);
}
/**
@@ -95,7 +101,17 @@
if (result != null) {
log.debug(
- "I could find an Element using the simple getElementById method: "
+ "I could find an Element using the simple getElementByIdType method: "
+ + result.getTagName());
+
+ return result;
+ }
+
+ result = IdResolver.getElementByIdUsingDOM(doc, id);
+
+ if (result != null) {
+ log.debug(
+ "I could find an Element using the simple getElementByIdUsingDOM method: "
+ result.getTagName());
return result;
@@ -166,6 +182,19 @@
return null;
}
+
+ /**
+ * Method getElementByIdUsingDOM
+ *
+ * @param doc
+ * @param id
+ *
+ */
+ private static Element getElementByIdUsingDOM(Document doc, String id) {
+ log.debug("getElementByIdUsingDOM() Search for ID " + id);
+ return doc.getElementById(id);
+ }
+
/**
* Method getElementByIdType
*
@@ -174,10 +203,12 @@
*
*/
private static Element getElementByIdType(Document doc, String id) {
-
log.debug("getElementByIdType() Search for ID " + id);
-
- return doc.getElementById(id);
+ WeakHashMap elementMap = (WeakHashMap) docMap.get(doc);
+ if (elementMap != null) {
+ return (Element)elementMap.get(id);
+ }
+ return null;
}
/**