de.interactive_instruments.ShapeChange.Target.XmlSchema
Class SchematronSchema

java.lang.Object
  extended by de.interactive_instruments.ShapeChange.Target.XmlSchema.SchematronSchema
All Implemented Interfaces:
MessageSource

public class SchematronSchema
extends Object
implements MessageSource


Nested Class Summary
static class SchematronSchema.ExtensionFunctionTemplate
           
static class SchematronSchema.RuleCreationStatus
           
 
Constructor Summary
SchematronSchema(Model mdl, Options o, ShapeChangeResult r, PackageInfo p)
          Ctor
 
Method Summary
protected  void addAssertion(ClassInfo ci, OclConstraint c)
          Add another OCL constraint and translate it into a Schematron <assert>, which is subsequently appended to the Schematron document within the proper <rule> context.
protected  void addAssertion(ClassInfo ci, SchematronConstraintNode.XpathFragment xpath, String text)
          Add an assertion statement embodied in an XpathFragment object and output it as a Schematron <assert> element, which is contained in a proper <rule> context.
 String getAndRegisterXmlName(ClassInfo ci)
          Auxiliary method to find out the full, namespace adorned name of a class from the the mapping or the model.
 String getAndRegisterXmlName(PropertyInfo pi)
          Auxiliary method to find out the full, namespace adorned name of a property from the model.
 String message(int mnr)
          This method returns messages belonging to the SchematronSchema object which accompanies the XmlSchema target.
protected  String messageText(int mnr)
          This is the message text provision proper.
 void registerNamespace(String xmlns)
          This auxiliary method registers a namespace prefix with the Schematron schema.
 void registerNamespace(String xmlns, ClassInfo ci)
          This special variant of the method above considers the class object to determine the full namespace uri.
 void registerNamespace(String xmlns, String ns)
          This auxiliary method registers a namespace (prefix and namespace proper) with the Schematron schema.
protected  SchematronConstraintNode translateConstraintAttributeToSchematronNode(OclNode.AttributeCallExp attr, SchematronConstraintNode enclosing, boolean negate)
          This method converts AttibuteCallExp objects into intermediary SchematronConstraintsNodes in a first step to realize these in Xpath code.
protected  SchematronConstraintNode translateConstraintIfExpToSchematronNode(OclNode.IfExp ifex, SchematronConstraintNode enclosing, boolean negate)
          This method will transform an OclNode.IfExp to an intermediary node structure suited for Schematron code generation.
protected  SchematronConstraintNode translateConstraintIterationToSchematronNode(OclNode.IterationCallExp iter, SchematronConstraintNode enclosing, boolean negate)
          This function treats the implemented IterationCallExp objects in an OCL expression.
protected  SchematronConstraintNode translateConstraintLetExpToSchematronNode(OclNode.LetExp letex, SchematronConstraintNode enclosing, boolean negate)
          This method will transform an OclNode.LetExp to an intermediary node structure suited for Schematron code generation.
protected  SchematronConstraintNode translateConstraintLiteralToSchematronNode(OclNode.LiteralExp lit, SchematronConstraintNode enclosing, boolean negate)
          This method is supposed to transform the OclNode Literals to an intermediary node structure which is suited for PL/SQL generation.
protected  SchematronConstraintNode translateConstraintOperationToSchematronNode(OclNode.OperationCallExp oper, SchematronConstraintNode enclosing, boolean negate)
          This function treats the implemented OperationCallExp objects in an OCL expression.
protected  SchematronConstraintNode translateConstraintToSchematronNode(OclNode ocl, SchematronConstraintNode enclosing, boolean negate)
          This function recursively descends into an OclConstraint following the OclNode structure.
 void write(String outputDirectory)
          This function serializes the generated Schematron schema to the given directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchematronSchema

public SchematronSchema(Model mdl,
                        Options o,
                        ShapeChangeResult r,
                        PackageInfo p)
Ctor

Parameters:
mdl - Model object
o - Options object
r - Result object
p - PackageInfo object
Method Detail

addAssertion

protected void addAssertion(ClassInfo ci,
                            OclConstraint c)
Add another OCL constraint and translate it into a Schematron <assert>, which is subsequently appended to the Schematron document within the proper <rule> context.

Parameters:
ci - ClassInfo object, which is context to the constraint.
c - OCL constraint. Must be invariant.

addAssertion

protected void addAssertion(ClassInfo ci,
                            SchematronConstraintNode.XpathFragment xpath,
                            String text)
Add an assertion statement embodied in an XpathFragment object and output it as a Schematron <assert> element, which is contained in a proper <rule> context. <let> elements are searched for identities and are merged including the necessary name corrections in the text.

Parameters:
ci - ClassInfo object, which is context to the constraint.
xpath - Assertion embodied in an XpathFragment object.
text - Explanatory text concerning the assertion
-

getAndRegisterXmlName

public String getAndRegisterXmlName(PropertyInfo pi)
Auxiliary method to find out the full, namespace adorned name of a property from the model. As a side effect the method makes the namespace also known to the Schematron schema, appending another <ns> element if necessary.

Parameters:
pi - PropertyInfo object
Returns:
Element name of property

getAndRegisterXmlName

public String getAndRegisterXmlName(ClassInfo ci)

Auxiliary method to find out the full, namespace adorned name of a class from the the mapping or the model. As a side effect the method makes the namespace also known to the Schematron schema, appending another <ns> element if necessary.

The method considers the mapping in first priority. If the class turns out to map to a basic type, null is returned instead of a name.

Parameters:
pi - ClassInfo object
Returns:
Element name of class

registerNamespace

public void registerNamespace(String xmlns,
                              String ns)
This auxiliary method registers a namespace (prefix and namespace proper) with the Schematron schema. It adds another <ns> element when the namespace occurs the first time.

Parameters:
xmlns - Namespace prefix
ns - Namespace proper

registerNamespace

public void registerNamespace(String xmlns)
This auxiliary method registers a namespace prefix with the Schematron schema. It adds another <ns> element when the namespace occurs the first time

Parameters:
xmlns - Namespace prefix

registerNamespace

public void registerNamespace(String xmlns,
                              ClassInfo ci)
This special variant of the method above considers the class object to determine the full namespace uri. If this is not successful it resorts to the method above, which uses the namespace mapping mechanism in the Options object.

Parameters:
xmlns - Namespace prefix
ci - ClassInfo object to fetch the namespace uri from

translateConstraintToSchematronNode

protected SchematronConstraintNode translateConstraintToSchematronNode(OclNode ocl,
                                                                       SchematronConstraintNode enclosing,
                                                                       boolean negate)

This function recursively descends into an OclConstraint following the OclNode structure. In doing so it generates an equivalent syntax tree which is more in line with Xpath syntax and its use in the Schematron schema.

Parameters:
ocl - OclNode of some level, initially called with OclNode.Expression
enclosing - Enclosing target construct, may be null
negate - Flag to indicate that a logical negation is to be pushed downwards
Returns:
Constructed SchematronConstraintNode tree. null if in error.

translateConstraintIterationToSchematronNode

protected SchematronConstraintNode translateConstraintIterationToSchematronNode(OclNode.IterationCallExp iter,
                                                                                SchematronConstraintNode enclosing,
                                                                                boolean negate)

This function treats the implemented IterationCallExp objects in an OCL expression. Doing so it generates intermediate code which is better suited for Schematron generation than the original OCL constructs.

Parameters:
iter - The IterationCallExp node to be processed
enclosing - Enclosing target construct
negate - Flag to indicate that a logical negation is to be pushed downwards
Returns:
Constructed SchematronConstraintNode tree

translateConstraintOperationToSchematronNode

protected SchematronConstraintNode translateConstraintOperationToSchematronNode(OclNode.OperationCallExp oper,
                                                                                SchematronConstraintNode enclosing,
                                                                                boolean negate)

This function treats the implemented OperationCallExp objects in an OCL expression. Doing so it generates intermediate code which is better suited for Schematron generation than the original OCL constructs.

Particularly, all logical operations are collected in Logic objects of the three flavors AND, OR and XOR, where AND and OR have as many as possible children. NOT is pushed downwards by using De Morgan's rule.

Parameters:
oper - The OperationCallExp node to be processed
enclosing - Enclosing target construct
negate - Flag to indicate that a logical negation is to be pushed downwards
Returns:
Constructed SchematronConstraintNode tree

translateConstraintAttributeToSchematronNode

protected SchematronConstraintNode translateConstraintAttributeToSchematronNode(OclNode.AttributeCallExp attr,
                                                                                SchematronConstraintNode enclosing,
                                                                                boolean negate)

This method converts AttibuteCallExp objects into intermediary SchematronConstraintsNodes in a first step to realize these in Xpath code.

Parameters:
attr - The AttibuteCallExp object
enclosing - If an enclosing Logic object is passed, the attribute must be of type Boolean. Otherwise an error is generated.
negate - A pushed down negation will only be considered if the attribute is of type Boolean.
Returns:
Constructed SchematronConstraintNode tree

translateConstraintLiteralToSchematronNode

protected SchematronConstraintNode translateConstraintLiteralToSchematronNode(OclNode.LiteralExp lit,
                                                                              SchematronConstraintNode enclosing,
                                                                              boolean negate)

This method is supposed to transform the OclNode Literals to an intermediary node structure which is suited for PL/SQL generation.

Parameters:
lit - The OclNode.Literal object
enclosing - If an enclosing Logic object is passed, the literal must be of type Boolean.
negate - A pushed down negation will only be considered if the literal is of type Boolean.
Returns:
Constructed SchematronConstraintNode tree

translateConstraintIfExpToSchematronNode

protected SchematronConstraintNode translateConstraintIfExpToSchematronNode(OclNode.IfExp ifex,
                                                                            SchematronConstraintNode enclosing,
                                                                            boolean negate)

This method will transform an OclNode.IfExp to an intermediary node structure suited for Schematron code generation.

Parameters:
ifex - The OclNode.IfExp object
enclosing - If an enclosing Logic object is passed, the type of the IfExp must be Boolean.
negate - A pushed down negation will switch the then and else parts.
Returns:
Constructed SchematronConstraintNode tree

translateConstraintLetExpToSchematronNode

protected SchematronConstraintNode translateConstraintLetExpToSchematronNode(OclNode.LetExp letex,
                                                                             SchematronConstraintNode enclosing,
                                                                             boolean negate)

This method will transform an OclNode.LetExp to an intermediary node structure suited for Schematron code generation.

Parameters:
letex - The OclNode.LetExp object
enclosing - If an enclosing Logic object is passed, the type of the LetExp must be Boolean.
negate - A pushed down negation will be passed to the body.
Returns:
Constructed SchematronConstraintNode tree

write

public void write(String outputDirectory)
This function serializes the generated Schematron schema to the given directory. The document name is derived from the name of the GML application schema. Serialization takes place only if at least one rule has been generated.

Parameters:
outputDirectory -

message

public String message(int mnr)

This method returns messages belonging to the SchematronSchema object which accompanies the XmlSchema target. The messages are retrieved by their message number. The organization corresponds to the logic in module ShapeChangeResult.

Specified by:
message in interface MessageSource
Parameters:
mnr - Message number
Returns:
Message text, including $x$ substitution points.

messageText

protected String messageText(int mnr)
This is the message text provision proper. It returns a message for a number.

Parameters:
mnr - Message number
Returns:
Message text or null


Copyright © 2015. All rights reserved.