|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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:
emp:id
attribute (the
http://www.uniba.sk/euromath/reserved
namespace)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).
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 |
---|
String getNamespaceUri()
INameListP<INewElementRuleP> getRootElements()
getNamespaceUri()
- root
element automatically belongs to the bounded URI. Schema instance should
compute this set only once and return immutable copy on each call.
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.
Iterator<String> getWarnings()
null
if there
were no warnings.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 SchemaPool.validate(Element)
to validate
this unknown element.
element
- element to be validated, always one of possible root
elements from this namespace.
SchemaException
- if something goes wrong in the process of
validation. The ISchema
instance must provide as much information
as possible about error. It should display path to errorneous element
with DOMUtils.getPathToRoot(org.w3c.dom.Node)
method for example.IElementRuleP getElementRule(Element element)
element
- the element. It must stay unchanged while returned
instance is used.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |