org.jdom.contrib.ids
Class IdFactory

java.lang.Object
  |
  +--org.jdom.DefaultJDOMFactory
        |
        +--org.jdom.contrib.ids.IdFactory

public class IdFactory
extends org.jdom.DefaultJDOMFactory

The 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 IdDocument which provides the method IdDocument.getElementById(java.lang.String) to look up an element given the value of its ID attribute.

The following code snippet demonstrates how to use the IdFactory with JDOM's SAXBuilder to create an IdDocument.

  SAXBuilder builder = new SAXBuilder();
  builder.setFactory(new IdFactory());

  IdDocument doc = (IdDocument)(builder.build(xmlDocument));

  Element elt = doc.getElementById(idValue);
 

Author:
Laurent Bihanic

Constructor Summary
IdFactory()
          Creates a new IdFactory object.
 
Method Summary
 org.jdom.Document document(org.jdom.Element rootElement)
           
 org.jdom.Document document(org.jdom.Element rootElement, org.jdom.DocType docType)
           
 org.jdom.Element element(java.lang.String name)
           
 org.jdom.Element element(java.lang.String name, org.jdom.Namespace namespace)
           
 org.jdom.Element element(java.lang.String name, java.lang.String uri)
           
 org.jdom.Element element(java.lang.String name, java.lang.String prefix, java.lang.String uri)
           
 
Methods inherited from class org.jdom.DefaultJDOMFactory
addContent, addNamespaceDeclaration, attribute, attribute, attribute, attribute, cdata, comment, docType, docType, docType, document, entityRef, entityRef, entityRef, processingInstruction, processingInstruction, setAttribute, text
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdFactory

public IdFactory()
Creates a new IdFactory object.
Method Detail

document

public org.jdom.Document document(org.jdom.Element rootElement,
                                  org.jdom.DocType docType)
Overrides:
document in class org.jdom.DefaultJDOMFactory

document

public org.jdom.Document document(org.jdom.Element rootElement)
Overrides:
document in class org.jdom.DefaultJDOMFactory

element

public org.jdom.Element element(java.lang.String name,
                                org.jdom.Namespace namespace)
Overrides:
element in class org.jdom.DefaultJDOMFactory

element

public org.jdom.Element element(java.lang.String name)
Overrides:
element in class org.jdom.DefaultJDOMFactory

element

public org.jdom.Element element(java.lang.String name,
                                java.lang.String uri)
Overrides:
element in class org.jdom.DefaultJDOMFactory

element

public org.jdom.Element element(java.lang.String name,
                                java.lang.String prefix,
                                java.lang.String uri)
Overrides:
element in class org.jdom.DefaultJDOMFactory


Copyright © 2004 Jason Hunter, Brett McLaughlin. All Rights Reserved.