IdFactory
defines methods to construct new ItemId
s. This factory is intended to build ItemId
s from the parameters passed to the various create methods and should not make an attempt to apply additional logic such as e.g. roundtrips to the server or resolution of Path
s. Similarly the SPI implementation namely the {@link RepositoryService} must be able to deal with the various formats ofan ItemId
, since a caller may not (yet) be aware of the uniqueID part of an ItemId.
IdFactory
extends the default JDOM factory to build documents that support looking up elements using their ID attribute. Looking-up elements by ID only works if a DTD is associated to the XML document as the information defining some attributes as IDs is only available from the DTD and not from the XML document itself.
The Documents created by this factory are instances of {@link IdDocument} which provides the method{@link IdDocument#getElementById} to look up an element given thevalue of its ID attribute.
The following code snippet demonstrates how to use the IdFactory
with JDOM's SAXBuilder to create an IdDocument
.
@author Laurent BihanicSAXBuilder builder = new SAXBuilder(); builder.setFactory(new IdFactory()); IdDocument doc = (IdDocument)(builder.build(xmlDocument)); Element elt = doc.getElementById(idValue);
|
|
|
|
|
|
|
|
|
|