Specialized Administration > Supporting Visualization and Publishing > WVS Publish Rules > Using Conditions in Publish Rules > Condition Elements
  
Condition Elements
The newer <condition> elements enable users to set up rules that look for more attributes on an EPMDocument, such as the lifecycle state (for instance, In Work, Released), the CAD type (for instance, Part, Assembly), and the container. This includes the introduction of a number of logical operators, such as AND, OR, and NOT
Attribute — The basic attribute element looks like this:
<attribute name="epmdoc_lifeCycleState" value="Released" />
Thename attribute of this element is the attribute to be checked on the EPMDocument being evaluated. One way to find all of the available attributes is to open a representation in Creo View and look at the properties. You see a series of epmdoc_* properties which are all available to the publish rules. In addition, any properties of the related WTPart are also available. These are also visible in Creo View and appear in the part_* format.
The value attribute in this example is the value to be compared against. If the value on the EPMDocument equals the value (case sensitive) on this Element, then this attribute is considered to be true.
Instead of using value, a user could use the regex XML attribute to use regular expressions, as in the following example:
<attribute name="epmdoc_CADName" regex=".*\.asm" />
In this case, the attribute would be considered true as long as the regular expression pattern returns a match for this EPMDocument.
Another use of the attribute element is to check if an attribute exists on the object, but it does not matter what the value is. This does not use either name or regex and looks like this:
<attribute name="MyIBA" />
Instance-of—The <instance-of> element is used like the <attribute> element, but is used to see if the object being evaluated is of the type specified. It looks like this:
<instance-of type=”wt.epm.EPMDocument” />
This evaluates in the publish rules to be true if the object is an EPMDocument. Alternatively, you could use:
<instance-of type="wt.doc.WTDocument" />
which would evaluate in the publish rules to be true if the object is a WTDocument.
structure — The <structure> element looks like this:
<structure type=”epm” />
<structure> is similar to the existing <structure-type type=”epm”> element, and behaves in the same way. See Compatibility of the Publish Rules Elements for more information on this new element.
Logical Operators — You can use the attribute, instance-of, and structure elements by themselves, but they become more powerful when they are combined using logical operators. The new supported operators are and, or and not. For example:
<and>
<attribute name="epmdoc_lifeCycleState" value="Released" />
<attribute name="epmdoc_docType" value="Assembly"/>
</and>
In this example, the object being evaluated must be both an assembly and in a released state for the statement to be true. Using or works in a very similar way:
<or>
<attribute name="epmdoc_lifeCycleState" value="Released" />
<attribute name="epmdoc_lifeCycleState" value="In Work" />
</or>
In this example, the object is either Released or In Work. There can also be more than two sub-elements for <and> and <or>; but both need to have at least two. For example:
<and>
<attribute name="epmdoc_lifeCycleState" value="Released" />
<attribute name="epmdoc_docType" value="Assembly"/>
<instance-of type=”EPMDocument” />
</and>
<not> works in a similar way, but can have only one sub-element. The example below indicates that the object being evaluated is not Released:
<not>
<attribute name="epmdoc_lifeCycleState" value="Released" />
</not>
To add to the capacity of these statements, you can use the logical operators nested within each other to create complex evaluations. The following example indicates that this is an Assembly that is either In Work or Released:
<and>
<attribute name="epmdoc_docType" value="Assembly"/>
<or>
<attribute name="epmdoc_lifeCycleState" value="In Work"/>
<attribute name="epmdoc_lifeCycleState" value="Released"/>
</or>
</and>
The next example indicates that the object is either an In Work Drawing or a Released Assembly
<or>
<and>
<attribute name="epmdoc_lifeCycleState" value="In Work"/>
<attribute name="epmdoc_docType" value="Drawing"/>
</and>
<and>
<attribute name="epmdoc_docType" value="Assembly"/>
<attribute name="epmdoc_lifeCycleState" value="Released"/>
</and>
</or>
The nesting can go as many levels deep as you want.
Condition Wrapper — All of the above elements must be wrapped in a <condition> element, as shown here:
<condition name="In Work">
<attribute name="epmdoc_lifeCycleState" value="In Work" />
</condition>
The “name” attribute is what is used by the<if> element (see below) to reference this condition. The <condition> elements can be under the root <rules> element, which implies they can be used for all <authoring-application> elements, or they can be under one specific <authoring-application> which means it can only be used in that context. The “name” attribute must be unique throughout the entire publish rules document. Here is another example using the logical operators:
<condition name="Released Assembly”>
<and>
<attribute name="epmdoc_lifeCycleState" value="Released" />
<attribute name="epmdoc_docType" value="Assembly"/>
</and>
</condition>
if condition— To use a defined <condition> element to control publishing, use the <if> element like this:
<if condition="Released Assembly">
<publish on="checkin" />
<publish on="create-representation" />
<publish on="schedule" />
</if>
Where a condition with name Released Assembly is defined in the rules (as above).