de.interactive_instruments.ShapeChange.TargetHelper
Class XpathHelper

java.lang.Object
  extended by de.interactive_instruments.ShapeChange.TargetHelper.XpathHelper
All Implemented Interfaces:
MessageSource

public class XpathHelper
extends Object
implements MessageSource


Nested Class Summary
static class XpathHelper.ExtensionFunctionTemplate
           
 
Field Summary
 HashMap<String,String> namespaces
           
 
Constructor Summary
XpathHelper(Options o, ShapeChangeResult r)
           
 
Method Summary
 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 XpathHelper object.
protected  String messageText(int mnr)
          This is the message text provision proper.
 void registerNamespace(String xmlns)
          This auxiliary method registers a well-known namespace prefix when the namespace occurs the first time
 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 method registers a namespace (prefix and namespace proper) when the namespace occurs the first time
protected  XpathConstraintNode translateConstraintAttributeToSchematronNode(OclNode.AttributeCallExp attr, XpathConstraintNode enclosing, boolean negate)
          This method converts AttibuteCallExp objects into intermediary SchematronConstraintsNodes in a first step to realize these in Xpath code.
protected  XpathConstraintNode translateConstraintIfExpToSchematronNode(OclNode.IfExp ifex, XpathConstraintNode enclosing, boolean negate)
          This method will transform an OclNode.IfExp to an intermediary node structure suited for Schematron code generation.
protected  XpathConstraintNode translateConstraintIterationToSchematronNode(OclNode.IterationCallExp iter, XpathConstraintNode enclosing, boolean negate)
          This function treats the implemented IterationCallExp objects in an OCL expression.
protected  XpathConstraintNode translateConstraintLiteralToSchematronNode(OclNode.LiteralExp lit, XpathConstraintNode 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  XpathConstraintNode translateConstraintOperationToSchematronNode(OclNode.OperationCallExp oper, XpathConstraintNode enclosing, boolean negate)
          This function treats the implemented OperationCallExp objects in an OCL expression.
protected  XpathConstraintNode translateConstraintToSchematronNode(OclNode ocl, XpathConstraintNode enclosing, boolean negate)
          This function recursively descends into an OclConstraint following the OclNode structure.
 XpathConstraintNode.XpathFragment translateConstraintToXpath(ClassInfo ci, OclConstraint c)
          Take an OCL constraint and translate it into an Xpath expression
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

namespaces

public HashMap<String,String> namespaces
Constructor Detail

XpathHelper

public XpathHelper(Options o,
                   ShapeChangeResult r)
Method Detail

registerNamespace

public void registerNamespace(String xmlns,
                              String ns)
This method registers a namespace (prefix and namespace proper) 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 well-known namespace prefix when the namespace occurs the first time

Parameters:
xmlns - Namespace prefix

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 registers the namespace

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,
                              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

translateConstraintToXpath

public XpathConstraintNode.XpathFragment translateConstraintToXpath(ClassInfo ci,
                                                                    OclConstraint c)
Take an OCL constraint and translate it into an Xpath expression

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

translateConstraintToSchematronNode

protected XpathConstraintNode translateConstraintToSchematronNode(OclNode ocl,
                                                                  XpathConstraintNode 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 XpathConstraintNode tree. null if in error.

translateConstraintIterationToSchematronNode

protected XpathConstraintNode translateConstraintIterationToSchematronNode(OclNode.IterationCallExp iter,
                                                                           XpathConstraintNode 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 XpathConstraintNode tree

translateConstraintOperationToSchematronNode

protected XpathConstraintNode translateConstraintOperationToSchematronNode(OclNode.OperationCallExp oper,
                                                                           XpathConstraintNode 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 XpathConstraintNode tree

translateConstraintAttributeToSchematronNode

protected XpathConstraintNode translateConstraintAttributeToSchematronNode(OclNode.AttributeCallExp attr,
                                                                           XpathConstraintNode 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 XpathConstraintNode tree

translateConstraintLiteralToSchematronNode

protected XpathConstraintNode translateConstraintLiteralToSchematronNode(OclNode.LiteralExp lit,
                                                                         XpathConstraintNode 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 XpathConstraintNode tree

translateConstraintIfExpToSchematronNode

protected XpathConstraintNode translateConstraintIfExpToSchematronNode(OclNode.IfExp ifex,
                                                                       XpathConstraintNode 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 XpathConstraintNode tree

message

public String message(int mnr)

This method returns messages belonging to the XpathHelper object. 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.