sk.baka.xml.schematic
Class DocumentSchema

java.lang.Object
  extended by sk.baka.xml.schematic.DocumentSchema

public class DocumentSchema
extends Object

DOM Document's content helper. For chosen operation returns all possibilities, that will result in valid document. Holds its own instance of SchemaReferences object.

Author:
Martin Vysny

Field Summary
 Document doc
          The document instance.
protected  SchemaReferences refs
          References instance.
 
Constructor Summary
DocumentSchema(Document doc, SchemaPool pool)
          Constructor.
 
Method Summary
 AttributeRule getAttributeRule(Attr attribute)
          Gets attribute rule for given attribute.
 ElementRule getElementRule(Element element)
          Returns rule for given element.
 SchemaReferences getRefs()
          Returns object containing references to loaded schema objects.
 String isDeletableAttribute(Attr attribute)
          Checks, whether given attribute is deletable from its element.
 void loadSchemas()
          Loads schemas for all given namespaces.
 void validate()
          Validates this document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

doc

public final Document doc
The document instance.


refs

protected final SchemaReferences refs
References instance.

Constructor Detail

DocumentSchema

public DocumentSchema(Document doc,
                      SchemaPool pool)
Constructor.

Parameters:
doc - the document instance.
pool - the schema pool.
Method Detail

loadSchemas

public void loadSchemas()
                 throws SchemaException,
                        IOException
Loads schemas for all given namespaces. If the schema is already loaded then it is not loaded again. It must be called before the Schema interface is used, to ensure that all schemata are properly loaded.

Throws:
SchemaException - if error happens during loading of schemas.
IOException - if i/o error occurs during the schema files deserialization.

getElementRule

public ElementRule getElementRule(Element element)
Returns rule for given element. It can be further queried for various info.

Parameters:
element - the context element, for which rule will be created.
Returns:
instance of element rule

isDeletableAttribute

public String isDeletableAttribute(Attr attribute)
Checks, whether given attribute is deletable from its element. Serves as shortcut for ElementRule.isDeletableAttribute(Attr).

Parameters:
attribute - attribute to check.
Returns:
null if attribute is deletable, error message otherwise.

getAttributeRule

public AttributeRule getAttributeRule(Attr attribute)
Gets attribute rule for given attribute. It can be used to validate textual value of attribute. It is OK to use this function. However, for subsequent queries to attribute's element please use ElementRule instance, it's more effective.

Parameters:
attribute - return rule for this attribute.
Returns:
rule for this attribute.

validate

public void validate()
              throws SchemaException
Validates this document.

Throws:
SchemaException - if something goes wrong in the process of validation.

getRefs

public SchemaReferences getRefs()
Returns object containing references to loaded schema objects.

Returns:
schema references object


Copyright © 2006 Martin Vysny - baka. All Rights Reserved.