org.dsmltools
Class DSMLDocumentImpl

java.lang.Object
  extended by DocumentImpl
      extended by org.dsmltools.DSMLDocumentImpl

public final class DSMLDocumentImpl
extends DocumentImpl

This class extends DocumentImpl, an implementation of the Document interface, to add DSML-specific functionality, such as directory-style validation.


Field Summary
static int TAB_SIZE
          The amount each line is indented from the previous one when a DSMLDocumentImpl is serialized.
 
Constructor Summary
DSMLDocumentImpl()
          When we create new DSML documents, this constructor ensures that they will automatically have the <dsml> node.
 
Method Summary
static void serialize(org.w3c.dom.Document xiDoc, java.io.OutputStream xiOut)
          This method takes a Document and writes its contents as a stream of DSML to the given OutputStream.
 void serialize(java.io.OutputStream xiOut)
          This method serializes this Document to the given OutputStream.
 void validate()
          This function calls validate(this, null) on this Document.
static void validate(org.w3c.dom.Document xiDoc)
          This function calls validate(xiDoc, null) on this Document - in other words, validation using the Document's schema.
static void validate(org.w3c.dom.Document xiDoc, LDAPSchema xiSchema)
          This function checks the directory data in the passed in Document for consistency at a directory (rather than XML) level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAB_SIZE

public static final int TAB_SIZE
The amount each line is indented from the previous one when a DSMLDocumentImpl is serialized.

See Also:
Constant Field Values
Constructor Detail

DSMLDocumentImpl

public DSMLDocumentImpl()
When we create new DSML documents, this constructor ensures that they will automatically have the <dsml> node.

Method Detail

validate

public void validate()
              throws DSMLRefException
This function calls validate(this, null) on this Document.

Throws:
DSMLRefException

validate

public static void validate(org.w3c.dom.Document xiDoc)
                     throws DSMLRefException
This function calls validate(xiDoc, null) on this Document - in other words, validation using the Document's schema.

Parameters:
xiDoc - The Document to validate
Throws:
DSMLRefException

validate

public static void validate(org.w3c.dom.Document xiDoc,
                            LDAPSchema xiSchema)
                     throws DSMLRefException
This function checks the directory data in the passed in Document for consistency at a directory (rather than XML) level. Specifically, it checks that the following are true: The structure of a DSML document is best ascertained from the DSML spec, but in summary: The schema is denoted by two sorts of XML tag - <class>, representing an objectclass, and <attribute-type>, representing the definition of an attribute. The data is enclosed in <entry> tags.

It takes the following actions on finding invalid bits of DSML: In some situations (DSML2LDAP) the schema information we are validating against is in LDAP structure form, and in others it's in XML form, as part of the same document as the data. This function copes with both, taking a LPDASchema object as a parameter. If this is null, it uses the schema information in the Document instead. Doing things this way prevents converting a massive schema into Document form, passing it into validate() and then converting half of it back to work with.

We assume any schema we are given in LDAPSchema form has been retrieved from a directory, and so don't validate it. (It's in the wrong form to do so, anyway.)

Parameters:
xiDoc - The Document to validate
xiSchema - An LDAPSchema object representing the schema to validate against, or null to use the Document's schema.
Throws:
DSMLRefException - Thrown if, in the course of validation, we encounter a reference to an external schema. This makes continuing with validation impossible, as we might remove valid data.

serialize

public void serialize(java.io.OutputStream xiOut)
This method serializes this Document to the given OutputStream.

Parameters:
xiDoc - Document to serialize

serialize

public static void serialize(org.w3c.dom.Document xiDoc,
                             java.io.OutputStream xiOut)
This method takes a Document and writes its contents as a stream of DSML to the given OutputStream.

Parameters:
xiDoc - Document to serialize
xiOut - OutputStream to serialize the document to