COSMOS ${releaseVersion} resource-modeling Project
Internal API Specification

org.eclipse.cosmos.rm.validation.internal.databuilders
Class ElementSchematronCacheBuilder

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.eclipse.cosmos.rm.validation.internal.databuilders.AbstractDataBuilder
          extended by org.eclipse.cosmos.rm.validation.internal.databuilders.ElementSchematronCacheBuilder
All Implemented Interfaces:
IDataBuilder, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ElementSchematronCacheBuilder
extends AbstractDataBuilder

This builder will extract the schematron from the definition document and create a map of namespace, element and schematron fragments. There are a few assumptions that are made:

  1. If a schematron rule is contained in an schema element, then it must be contained within an element or element type declaration
  2. A schematron rule associated with an element or element type declaration must be contained in a schema element that defines a target namespace.
  3. A schematron rule that is associated with an element or element type declaration is always applied.
  4. In the presence of the ruleBindings element, a definition document that only contains a schematron rule is applied to a document only if it is bound to the rule based on the content of the ruleBindings element.
  5. In the absense of the ruleBindings element, a definition document that only contains a schematron rule is applied to ALL instance documents.


Nested Class Summary
static class ElementSchematronCacheBuilder.RuleBindings
          A data structure that stores the schematron rule bindings
 
Field Summary
protected  java.lang.StringBuffer buffer
          Stores the schematron rule
static java.lang.String ID
          The ID of this data builder
protected  java.lang.String name
          Stores an element name declaration
protected  java.lang.String targetNamespace
          Stores the target namespace of the current schema being processed
protected  java.lang.String type
          Stores the name of an element type declaration
 
Fields inherited from class org.eclipse.cosmos.rm.validation.internal.databuilders.AbstractDataBuilder
locator
 
Constructor Summary
ElementSchematronCacheBuilder()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 java.lang.Object getDataStructure()
          Returns the data structure.
 byte getPhase()
          Specifies the phase that this data builder is active during parsing.
 java.util.Map getSchematronOutputs()
           
protected  boolean isRuleTest(java.lang.String localName)
          Answer true if the currently encountered localName is one of the children of sch:rule elements that tests element data for expression conditions.
protected  java.lang.StringBuffer printAttributes(org.xml.sax.Attributes attributes)
           
protected  java.lang.StringBuffer printReplaceSMLFNAttributes(org.xml.sax.Attributes attributes)
           
protected  java.lang.StringBuffer printRuleAttributes(org.xml.sax.Attributes attributes)
           
protected  java.lang.StringBuffer printSchNamespaceAttributes(org.xml.sax.Attributes attributes)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          This is used to determine the target name space of the document currently being parsed
 
Methods inherited from class org.eclipse.cosmos.rm.validation.internal.databuilders.AbstractDataBuilder
appendToErrorMessage, comment, endDefinitions, endInstances, getCurrentPhase, getDefaultNamespace, getErrorMessage, getFilePath, getPrefixMap, getTargetNamespace, isStructureValid, setDefaultNamespace, setDocumentLocator, setErrorMessage, setFilePath, setPrefixMap, setStructureValidity, setTargetNamespace, startDefinitions, startInstances, tokenizeName
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xml.sax.ContentHandler
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping
 

Field Detail

ID

public static final java.lang.String ID
The ID of this data builder

See Also:
Constant Field Values

buffer

protected java.lang.StringBuffer buffer
Stores the schematron rule


name

protected java.lang.String name
Stores an element name declaration


type

protected java.lang.String type
Stores the name of an element type declaration


targetNamespace

protected java.lang.String targetNamespace
Stores the target namespace of the current schema being processed

Constructor Detail

ElementSchematronCacheBuilder

public ElementSchematronCacheBuilder()
Method Detail

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class AbstractDataBuilder
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Description copied from class: AbstractDataBuilder
This is used to determine the target name space of the document currently being parsed

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class AbstractDataBuilder
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)

isRuleTest

protected boolean isRuleTest(java.lang.String localName)
Answer true if the currently encountered localName is one of the children of sch:rule elements that tests element data for expression conditions. Known "testing" elements include assert, report, and diagnostic elements.

Parameters:
localName -
Returns:

printRuleAttributes

protected java.lang.StringBuffer printRuleAttributes(org.xml.sax.Attributes attributes)

printReplaceSMLFNAttributes

protected java.lang.StringBuffer printReplaceSMLFNAttributes(org.xml.sax.Attributes attributes)

printSchNamespaceAttributes

protected java.lang.StringBuffer printSchNamespaceAttributes(org.xml.sax.Attributes attributes)

printAttributes

protected java.lang.StringBuffer printAttributes(org.xml.sax.Attributes attributes)

getDataStructure

public java.lang.Object getDataStructure()
Description copied from interface: IDataBuilder
Returns the data structure. The type of the structure must be specified as part of the specification of the class that implements this interface.

Returns:
The data structure

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
See Also:
DefaultHandler.characters(char[], int, int)

getPhase

public byte getPhase()
Description copied from interface: IDataBuilder
Specifies the phase that this data builder is active during parsing. The parser parses the sml document in two parts: Definitions and Instances phases. The valid values are as follows:
 ISMLConstants.DEFINITIONS_PHASE -databuilder is active during the parsing of the definitions elements
 ISMLConstants.INSTANCES_PHASE -databuilder is active during the parsing of the instances elements
 ISMLConstants.DEFINITIONS_INSTANCES_PHASE - databuilder is active during the parsing of the definitions and instances elements
 

Specified by:
getPhase in interface IDataBuilder
Overrides:
getPhase in class AbstractDataBuilder
Returns:
a phase that this databuilder will be active
See Also:
IDataBuilder.getPhase()

getSchematronOutputs

public java.util.Map getSchematronOutputs()

COSMOS ${releaseVersion} resource-modeling Project
Internal API Specification