sk.uniba.euromath.document.schema.plug
Interface ISchema

All Known Implementing Classes:
SchemaImpl

public interface ISchema

Schema returns various information regarding allowed document structure. It is created for every namespace, and each Schema returns elements from its namespace only. Because class can be used by multiple documents simultaneously, each method must be thread-safe.

Because of the identification system, in-memory Document is slightly modified. Schema instance must be aware that:

It is strictly forbidden to modify given document in any way!

Document can be changed between any two calls without further notification to Schema. Thus, Schema must be 'stateless' - it must not change its internal variables due to document contents. In other hand, it is guaranteed that when any Schema function is being executed, the document stays unmodified.

The schema should be checked for all schema mismatches in the loading time. The document is valid when some schema method is called and it must be valid when the suggested modifications are made. Hence the document is always valid and the only method that is allowed to throw an exception is the validate() method. However the method may throw an exception to signalise wrong parameters, invalid document etc (these exceptions signalise that there is something wrong with plugins or EuroMath itself).

Author:
Martin Vysny

Method Summary
 IElementRuleP getElementRule(Element element)
          Returns rule representing given existing element.
 INameListP<IAttributeRuleP> getExportedAttributes()
           Computes all attributes defined in this schema, regardless of element, which they are bound to.
 String getNamespaceUri()
          Returns URI for which the Schema works.
 INameListP<INewElementRuleP> getRootElements()
          Returns list of possible local names of the root elements.
 Iterator<String> getWarnings()
          Returns warnings that occured during schema loading.
 void validate(Element element)
           Validates given root element.
 

Method Detail

getNamespaceUri

String getNamespaceUri()
Returns URI for which the Schema works. Schema may accept elements/attributes from other namespaces, however it should not attempt to define their content.

Returns:
URI to which the Schema is bound.

getRootElements

INameListP<INewElementRuleP> getRootElements()
Returns list of possible local names of the root elements. URI is fixed and can be returned with function getNamespaceUri()- root element automatically belongs to the bounded URI. Caller guarantees that it won't modify this set. In exchange, Schema must cache this set.

Returns:
set of strings representing local names of the root elements.

getExportedAttributes

INameListP<IAttributeRuleP> getExportedAttributes()

Computes all attributes defined in this schema, regardless of element, which they are bound to. Returned array must NOT be modifed in any way. These attributes are called exported - they can be inserted into other namespaces.

This list serves for purpose of adding attributes of this namespace to elements from another namespace. Thus, if there are 2 or more attributes defined with same QName in schema, they cannot be returned here. That would raise ambiguity, because attributes are denoted only by QName, and we would have to select from more rules.

Local attributes have empty URI instead of its own namespace URI, so empty URI must be replaced by its namespace URI.

Result should be computed when object is created.

Returns:
all attributes of this schema. Result list must contain AttributeRule instances.

getWarnings

Iterator<String> getWarnings()
Returns warnings that occured during schema loading. Items of iterator must NOT be modified nor deleted.

Returns:
Iterator of String representing warnings, or null if there were no warnings.

validate

void validate(Element element)
              throws SchemaException

Validates given root element. It must be full validation, no elements nor texts must not be skipped. If this element is not valid, exception must be thrown.

When element from another namespace uri is encountered in the process of validation, just call ValidationContextP.validate() to validate this unknown element.

The only exception to this rule is emp:id attribute, which the schema must ignore.

Parameters:
element - element to be validated, always one of possible root elements from this namespace.
Throws:
SchemaException - if something goes wrong in the process of validation. The Schema instance must provide as much information as possible about error. It should display path to errorneous element with getPathToRoot() method of EuromathSchemaProvider class.

getElementRule

IElementRuleP getElementRule(Element element)
Returns rule representing given existing element. If the document is not valid then the rule returned is correct if and only if the rule can be identified from the name of the element - the element is said to be context-free.

Parameters:
element - the element. It must stay unchanged while returned instance is used.
Returns:
rule, used to modify contents of given element.


Copyright © 2003-2006 null. All Rights Reserved.