org.inria.ns.reflex.processor.asl
Class MasterSchema

java.lang.Object
  extended by org.inria.ns.reflex.processor.asl.MasterSchema

public class MasterSchema
extends Object

A MasterSchema hold the ordered list of schemata needed when checking an XML document.

A schema request cause a lookup in the catalog. When a validation is expected on an element or attribute (or when another schema resource is needed), the master schema will retrieve the schema that contains the expected definition.

Handling augmentations (PSVI)

The same XML document may be augmented with typed datas that may vary according to the application. These variations are applied by the host processor instance that deliver a specific schema assembly (the processor instance hold the catalogs responsible of delivering schema instances).

Thus, there is a single master schema for each processor instance.

A typed data can be retrieved from a node if a schema has defined a type for it. The typed data is kept as long as there is a reference to the node (that can be kept indirectly through its owner document).

Author:
Philippe Poulard
See Also:
GlobalSchema

Method Summary
 void augment(Node node, TypedData data)
          Augments the informations of a node with a typed data.
 GlobalSchema getGlobalSchema(QName qName)
          Return the global schema bound to the namespace URI of the given QName.
 GlobalSchema getGlobalSchema(String namespaceURI)
          Return the global schema bound to the given namespace URI.
static MasterSchema getMasterSchema(DataSet dataSet)
          Find the current master schema in use : check the presence of a schema client handler and get its master schema get those from the PI that owns the current dataset This method can help to retrieve the right master schema in use, as the caller's PI is not the same as the schema's PI : while validating, as the caller's PI has been put in the data set, this method will get it anyway.
 TypedData getTypedData(Node node)
          Return the typed data (PSVI) of a node.
static MasterSchema newMasterSchema(ProcessorInstance pi)
          Create a new master schema.
 void storeSchemaInstance(Schema schema)
          Stores a schema instance in this master schema.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newMasterSchema

public static MasterSchema newMasterSchema(ProcessorInstance pi)
Create a new master schema.

Parameters:
pi - The non-null processor instance that creates this master schema. If a master schema already exists for the given processor instance, it will be returned, otherwise a new one will be created. The master schema is hold by the processor instance within its attributes (which key is the name of this class).
See Also:
ProcessorInstance.setAttribute(Object, Object)

getMasterSchema

public static MasterSchema getMasterSchema(DataSet dataSet)
Find the current master schema in use :
  1. check the presence of a schema client handler and get its master schema
  2. get those from the PI that owns the current dataset

This method can help to retrieve the right master schema in use, as the caller's PI is not the same as the schema's PI : while validating, as the caller's PI has been put in the data set, this method will get it anyway. This is important for PSVI, as augmented datas are attached to a PI.

If this method is called after validation, the master schema will be those attached to the caller PI.

If this method is called while validating, the master schema will be those attached to the caller PI, not those running the schema.

If this method is called before validation, a new master schema will supplied and attached to the PI of the given data set.

Parameters:
dataSet - The data set.
Returns:
The master schema in use, that might be a new one.

storeSchemaInstance

public void storeSchemaInstance(Schema schema)
Stores a schema instance in this master schema. In fact, the schema is stored in the global schema that has the same namespace URI.

Parameters:
schema - The schema to store.
See Also:
GlobalSchema

getGlobalSchema

public GlobalSchema getGlobalSchema(QName qName)
Return the global schema bound to the namespace URI of the given QName.

Parameters:
qName - The QName that has the namespace URI of the global schema to retrieve.
Returns:
The global schema bound to the namespace URI of the given QName, never null.

getGlobalSchema

public GlobalSchema getGlobalSchema(String namespaceURI)
Return the global schema bound to the given namespace URI.

Parameters:
namespaceURI - The namespace URI of the global schema to retrieve.
Returns:
The global schema bound to the given namespace URI, never null.

augment

public void augment(Node node,
                    TypedData data)
Augments the informations of a node with a typed data. This is known as Post-Schema Validation Infoset.

Parameters:
node - The node to augment.
data - The typed data to assign to the node.
See Also:
getTypedData(Node)

getTypedData

public TypedData getTypedData(Node node)
Return the typed data (PSVI) of a node.

Parameters:
node - The node.
Returns:
The typed data for the node, null if not defined.
See Also:
augment(Node, TypedData)