none
Dissecting the Process Flowchart Validation Rules RRS feed

  • General discussion

  • To get a better understanding of how a rule set is structured, let’s examine in detail the rule set provided for checking flowcharts.  One cannot see the actual rules using the Visio user interface.  However, a quick way to see how the rule objects are set up is to save a drawing that contains rules (such as a flowchart) as a .vdx file and then view it using an XML viewer such as XML Notepad. 

    David Parker has also produced a free tool for examining rules.  See his post at http://bvisual.spaces.live.com/blog/cns!3350D61BC93733A9!1852.entry 

    I'll post the information on the first two rules in this intro and then respond to my own post with descriptions of the remaining rules.

    ValidationRuleSet Object

    The RuleSet is an object that holds a collection of rules

    ·         ID: 1

    ·         NameU :  Flowchart

    ·         Description: Verify that Flowchart shapes are connected properly.

    NameU is the universal name of the ValidationRuleSet object and Description states the purpose of the ValidationRuleSet object.  There are eleven rules defined within this ValidationRuleSet.

    ValidationRule Objects

    NameU is the universal name of the Rule object.

    Category represents the text displayed in the Category column of the Issues window.

    Description states the purpose of the ValidationRule object.

    RuleTarget represents the TargetType property of the ValidationRule object.  Rules can be targeted at the shape, page, or document level.

    ·         =0. The rule applies to shapes in the document.

    ·         =1. The rule applies to pages in the document.

    ·         =2. The rule applies to the document itself.

    RuleFilter in the .vdx file is the FilterExpression property of the ValidationRule object.  This defines a logical expression that determines whether the validation rule should be applied to a target object.

    When you validate a diagram by calling the Validate method or by clicking Check Diagram on the Process tab, Visio uses the expression that you set as the FilterExpression property value to determine whether a target object must satisfy the validation rule. If the filter expression evaluates to True, Visio uses the TestExpression property value to determine whether to generate an issue for the target object. If the filter expression evaluates to False, Visio does not apply the validation rule to the target object during validation.

    The syntax for the FilterExpression property value is the same as that for a ShapeSheet expression. When you set the FilterExpression property, Visio does not validate the syntax of the filter expression. If the expression is not syntactically correct, Visio does not apply the validation rule to the target object during validation.

    RuleTest in the .vdx file is the TestExpression property value of the ValidationRule object.

    The syntax for the TestExpression property value is the same as that for a ShapeSheet expression. When you set the TestExpression property value, Visio does not check the syntax of the test expression. If the test expression is not syntactically correct, the evaluation of the expression fails during validation and Visio generates a validation issue at that time.

    The default property values of a validation rule are as follows:

    ·         Category = [empty]

    ·         Description = "Unknown"

    ·         FilterExpression = [empty]

    ·         Ignored = False

    ·         TargetType = visRuleTargetShape

    ·         TestExpression = [empty]

    Following are the eleven rules defined within the flowchart template for checking basic flowchart diagrams.

    Rule #1

    ID

    1

    NameU

    UngluedConnector

    Category

    Connectivity

    Description

    Connector is not glued at both ends.

    RuleFilter

    ROLE()=1

    RuleTest

    AND(AGGCOUNT(GLUEDSHAPES(4)) = 1, AGGCOUNT(GLUEDSHAPES(5)) = 1)

    The rule checks that a connector is glued at both ends. 

    ROLE()=1 as the RuleFilter expression means to select all connector shapes.

    GLUEDSHAPES is a shape method that returns an array that contains the identifiers of the shapes that are glued to a shape.  The method takes a flag that specifies the dimensionality and directionality of the connection points of the shapes to be returned. The flag parameter options are itemized in visGluedShapesFlags enumeration:

    ·         visGluedShapesIncoming2D=4.  If the source object is a 1D shape, return the 2D shape to which the begin point is glued.

    ·         visGluedShapesOutgoing2D=5.  If the source object is a 1D shape, return the 2D shape to which the end point is glued.

    AGGCOUNT counts how many shapes are returned by the GLUEDSHAPES method.

    In words, the RuleFilter says to look at all connector shapes.  For each connector shape found check that the begin point is glued to exactly one 2D shape and the end point is glued to exactly one 2D shape.

     

    Rule #2

    ID

    2

    NameU

    StartWithoutTerminator

    Category

    Start / End

    Description

    Flowchart shape has no incoming connectors and is not a Start/End shape.

    RuleFilter

    AND(OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart")),NOT(OR(HASCATEGORY("Start/End"),STRSAME(LEFT(MASTERNAME(750),9),"Start/End"),STRSAME(LEFT(MASTERNAME(750),10),"Terminator"))))

    RuleTest

    AGGCOUNT(GLUEDSHAPES(1)) > 0

    This somewhat complex looking RuleFilter is expressed below with some added indentation to aid in understanding.

    AND(

       OR(    HASCATEGORY("Flowchart"),

              ONLAYER("Flowchart")

         ),

       NOT(OR(HASCATEGORY("Start/End"),

              STRSAME(LEFT(MASTERNAME(750),9),"Start/End"),

              STRSAME(LEFT(MASTERNAME(750),10),"Terminator")

          )  )

       )

    The shape has to either have the Flowchart category defined, HASCATEGORY(“Flowchart”), meaning there is a ShapeSheet cell User.msvShapeCategories=”Flowchart”, or the shape is on the “Flowchart” layer.

    The shape must also not have a cell User.msvShapeCategories=”Start/End”, not be created from the “Start/End” master and not be created from a “Terminator” master.  MASTERNAME is a ShapeSheet function that returns a shape’s master name as a string. The argument is used to specify a language for the string the function returns.  Use a value of 0 (default value) to specify the local language. Use 750 to specify universal language.

    If the shape satisfies these RuleFilter conditions, then the FilterExpresssion is applied. GLUEDSHAPES(1) returns a list of 1D shapes whose end points are glued to this shape. AGGCOUNT(GLUEDSHAPES(1))>0 states that the target shape must therefore have at least one incoming connector.

    Wednesday, December 23, 2009 2:06 AM
    Moderator

All replies

  • Here are rules 3-7.

    Rule #3

    ID

    3

    NameU

    EndWithoutTerminator

    Category

    Start / End

    Description

    Flowchart shape has no outgoing connectors and is not a Start/End shape.

    RuleFilter

    AND(OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart")),NOT(OR(HASCATEGORY("Start/End"),STRSAME(LEFT(MASTERNAME(750),9),"Start/End"),STRSAME(LEFT(MASTERNAME(750),10),"Terminator"))))

    RuleTest

    AGGCOUNT(GLUEDSHAPES(2)) > 0

    The RuleFilter is identical to that of rule #2. 

    GLUEDSHAPES(2) returns a list of 1D shapes whose begin points are glued to this shape. AGGCOUNT(GLUEDSHAPES(2))>0 states that the target shape must therefore have at least one outgoing connector.

     

    Rule #4

    ID

    4

    NameU

    NoStartTerminator

    Category

    Start / End

    Description

    Flowchart does not start with a Start/End shape.

    RuleTarget

    1

    RuleFilter

    AGGCOUNT(FILTERSET(SHAPESONPAGE(), "OR(HASCATEGORY(""Flowchart""),ONLAYER(""Flowchart""))")) > 0

    RuleTest

    AGGCOUNT(FILTERSET(SHAPESONPAGE(), "AND(OR(HASCATEGORY(""Start/End""),STRSAME(LEFT(MASTERNAME(750),9),""Start/End""),STRSAME(LEFT(MASTERNAME(750),10),""Terminator"")),AGGCOUNT(CONNECTEDSHAPES(2))>0)")) > 0

    RuleTarget=1 sets the target of this rule to be the page.  When no RuleTarget is specified, the default is to target shapes.

    The RuleFilter filters the collection of all shapes on the page, SHAPESONPAGE(), to include only those shapes that are either assigned to the “Flowchart” category, HASCATEGORY(“Flowchart”), or have been assigned to a Flowchart layer.  The AGGCOUNT function is used to check that the count in this collection is >0.

    The RuleTest is shown below with indentation added for easier interpretation.

    AGGCOUNT(

       FILTERSET( SHAPESONPAGE(),

                 "AND(OR(HASCATEGORY(""Start/End""),

                         STRSAME(LEFT(MASTERNAME(750),9),""Start/End""),

                        STRSAME(LEFT(MASTERNAME(750),10),""Terminator"")),

                    AGGCOUNT(CONNECTEDSHAPES(2))>0)")

       ) > 0

    The innermost portion

                      OR(HASCATEGORY(""Start/End""),

                         STRSAME(LEFT(MASTERNAME(750),9),""Start/End""),

                        STRSAME(LEFT(MASTERNAME(750),10),""Terminator"")),

    specifies that the shape must either be defined with category “Start/End”, i.e., it has msvShapeCategories=”Start/End”, or it is derived from a master named Start/End or it is derived from a master named Terminator.

    CONNECTEDSHAPES(2) is a shape method that returns a list of shapes connected to the shape which are associated with outgoing connectors.

    AGGCOUNT(CONNECTEDSHAPES(2))>0 says there must be at least one shape connected with an outgoing connector.

    FILTERSET selects all SHAPESONPAGE and then filters these shapes to include only those that are start or end terminator shapes which also have at least one outgoing connector.  The outer most AGGCOUNT checks that at least one shape satisfies these conditions.

    In summary the rule checks for at least one Start/End or Terminator shape that has outgoing connectors that are connected to something.

     

    Rule #5

    ID

    5

    NameU

    NoEndTerminator

    Category

    Start / End

    Description

    Flowchart does not end with a Start/End shape.

    RuleTarget

    1

    RuleFilter

    AGGCOUNT(FILTERSET(SHAPESONPAGE(), "OR(HASCATEGORY(""Flowchart""),ONLAYER(""Flowchart""))")) > 0

    RuleTest

    AGGCOUNT(FILTERSET(SHAPESONPAGE(), "AND(OR(HASCATEGORY(""Start/End""),STRSAME(LEFT(MASTERNAME(750),9),""Start/End""),STRSAME(LEFT(MASTERNAME(750),10),""Terminator"")),AGGCOUNT(CONNECTEDSHAPES(1))>0)")) > 0

    The rule is identical to rule #4 except that CONNECTEDSHAPES(1) returns a list of shapes connected to the shape which are associated with incoming connectors. Thus the rule checks for at least one terminating shape with incoming connectors that are connected to something.

     

    Rule #6

    ID

    6

    NameU

    UnconnectedShape

    Category

    Connectivity

    Description

    Flowchart shape is not connected to any other shape.

    RuleFilter

    OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart"))

    RuleTest

    AGGCOUNT(CONNECTEDSHAPES(0)) > 0

    The RuleFilter looks for shapes that have category “Flowchart” or are on a “Flowchart” layer.

    The shape must be connected to at least one other shape.  CONNECTEDSHAPES(0) returns a list of shapes connected to the shape via either incoming or outgoing connections.

     

    Rule #7

    ID

    7

    NameU

    TerminatorInMiddle

    Category

    Connectivity

    Description

    Start/End shape has both incoming and outgoing connectors.

    RuleFilter

    OR(HASCATEGORY("Start/End"),STRSAME(LEFT(MASTERNAME(750),9),"Start/End"),STRSAME(LEFT(MASTERNAME(750),10),"Terminator"))

    RuleTest

    NOT(AND(AGGCOUNT(CONNECTEDSHAPES(1))>0,AGGCOUNT(CONNECTEDSHAPES(2))>0))

    The RuleFilter finds terminator shapes by checking msvShapeCategories=”Start/End” or shapes that inherit from master “Start/End” or from master “Terminator”.

    The RuleText counts both incoming connectors (CONNECTEDSHAPES(1)>0) and outgoing connectors (CONNECTEDSHAPES(2)>0).  A terminator should not have both incoming and outgoing connectors.

     

    Wednesday, December 23, 2009 2:09 AM
    Moderator
  • Here are rules 8-11.

    Rule #8

    ID

    8

    NameU

    TooFewOutConns

    Category

    Connectivity

    Description

    Decision shape should have more than one outgoing connector.

    RuleFilter

    OR(HASCATEGORY("Decision"),STRSAME(LEFT(MASTERNAME(750),8),"Decision"))

    RuleTest

    AGGCOUNT(GLUEDSHAPES(2)) > 1

    The RuleFilter checks for shapes that either have a cell msvShapeCategories=”Decision” or are derived from a master named “Decision”.

    GLUEDSHAPES(2) returns a list of 1D shapes whose begin points are glued to this shape. AGGCOUNT(GLUEDSHAPES(2))>0 states that the Decision shape must therefore have more than one outgoing connector.

     

    Rule #9

    ID

    9

    NameU

    NonFlowchartShape

    Category

    Connectivity

    Description

    Connected shape is not recognized as a Flowchart shape.

    RuleFilter

    NOT(OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart")))

    RuleTest

    AGGCOUNT(GLUEDSHAPES(0)) = 0

    The RuleFilter checks for shapes that do not have a cell msvShapeCategories=”Flowchart” and are not on a layer named “Flowchart”.

    Any shapes found by the RuleFilter are checked.  GLUEDSHAPES(0) returns a list of all 1D shapes that are glued to this shape.  AGGCOUNT(GLUEDSHAPES(0))=0 states that the shape has no glued shapes.  Therefore, a validation issue is raised only if there is a non flowchart shape that is glued to something else.  A non flowchart shape can exist in the drawing without raising a validation issue as long as it is not glued to another shape.

     

     

    Rule #10

    ID

    10

    NameU

    NoShapeText

    Category

    Text

    Description

    Flowchart shape has no text label.

    RuleFilter

    OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart"))

    RuleTest

    NOT(STRSAME(SHAPETEXT(TheText), ""))

    The RuleFilter checks for “Flowchart” shapes either defined by category or assigned to a layer.

    The RuleTest compares the shape text to the null string.  Therefore, any flowchart shape raises an issue if it has no text.

     

    Rule #11

    ID

    11

    NameU

    OutsideCFF

    Category

    Cross - Functional

    Description

    Flowchart shapes should belong to a Swimlane.

    RuleTarget

    1

    RuleFilter

    AGGCOUNT(FILTERSET(SHAPESONPAGE(),"HASCATEGORY(""Swimlane"")"))>0

    RuleTest

    AGGCOUNT(FILTERSET(SHAPESONPAGE(),"AND(OR(HASCATEGORY(""Flowchart""),ONLAYER(""Flowchart"")),AGGCOUNT(FILTERSET(PARENTCONTAINERS(),""HASCATEGORY(""""Swimlane"""")""))=0)"))=0

    The last rule is a page level check (RuleTarget=1).

    The RuleFilter gets all Swimlane shapes.  If there are no swimlanes on the page, this rule has no effect.

    If there are swimlanes on the page the RuleTest checks to see that all Flowchart shapes are within a swimlane.  The RuleTest is displayed below with indentation for easier interpretation.

    AGGCOUNT(

       FILTERSET(

          SHAPESONPAGE(),

          "AND(OR(HASCATEGORY(""Flowchart""),ONLAYER(""Flowchart"")),

               AGGCOUNT(FILTERSET(PARENTCONTAINERS(),

                                  ""HASCATEGORY(""""Swimlane"""")""))=0)")

       )=0

    The outer FILTERSET selects all SHAPESONPAGE and filters these to include only shapes that are Flowchart shapes (which have either the Flowchart category defined or are on a Flowchart layer) AND whose PARENTCONTAINERS are in the Swimlane category.  If any flowchart shape does not have a swimlane parent, the outer ADDCOUNT will be greater than 0.

    Wednesday, December 23, 2009 2:11 AM
    Moderator