org.apache.xml.security.utils
Class IdResolver

java.lang.Object
  extended by org.apache.xml.security.utils.IdResolver

public class IdResolver
extends java.lang.Object

Purpose of this class is to enable the XML Parser to keep track of ID attributes. This is done by 'registering' attributes of type ID at the IdResolver. This is necessary if we create a document from scratch and we sign some resources with a URI using a fragment identifier...
The problem is that if you do not validate a document, you cannot use the getElementByID functionality. So this modules uses some implicit knowledge on selected Schemas and DTDs to pick the right Element for a given ID: We know that all @Id attributes in an Element from the XML Signature namespace are of type ID.

Author:
$Author: coheigea $
See Also:
"Identity Crisis" on xml.com

Method Summary
static org.w3c.dom.Element getElementById(org.w3c.dom.Document doc, java.lang.String id)
          Method getElementById
static int isElement(org.w3c.dom.Element el, java.lang.String id, org.w3c.dom.Element[] els)
           
static void registerElementById(org.w3c.dom.Element element, org.w3c.dom.Attr id)
          Method registerElementById
static void registerElementById(org.w3c.dom.Element element, java.lang.String idValue)
          Method registerElementById
static void unregisterDocument(org.w3c.dom.Document doc)
          Force a removal of a registered document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerElementById

public static void registerElementById(org.w3c.dom.Element element,
                                       java.lang.String idValue)
Method registerElementById

Parameters:
element - the element to register
idValue - the value of the ID attribute

unregisterDocument

public static void unregisterDocument(org.w3c.dom.Document doc)
Force a removal of a registered document. Any element id associated with this document will be removed from the weak reference map.

Parameters:
doc - the DOM document that is to be removed from the map.

registerElementById

public static void registerElementById(org.w3c.dom.Element element,
                                       org.w3c.dom.Attr id)
Method registerElementById

Parameters:
element - the element to register
id - the ID attribute

getElementById

public static org.w3c.dom.Element getElementById(org.w3c.dom.Document doc,
                                                 java.lang.String id)
Method getElementById

Parameters:
doc - the document
id - the value of the ID
Returns:
the element obtained by the id, or null if it is not found.

isElement

public static int isElement(org.w3c.dom.Element el,
                            java.lang.String id,
                            org.w3c.dom.Element[] els)


Copyright © 2000-2011 The Apache Software Foundation. All Rights Reserved.