As you said, the obvious way to handle this requirement is to use two TN processing rules, the first which matches MessageType == ‘X’, the second which matches MessageType == ‘Y’.
Another way would be to check the attribute’s value in code in your own TN bizdoc processing service, but this would mean all documents regardless of MessageType would need to be processed by the TN processing rule that called your service. That may or may not suit you, depending on your needs.
The only other way I can think of doing this with the one processing rule, and by far the trickiest, would be to use a custom transformation service on the extracted attribute to convert it to a boolean, so that you only have to check the one value in the TN processing rule’s extended criteria. I’d actually recommend leaving the existing MessageType extracted attribute alone, and creating a new one that you can transform to a boolean called something like MessageTypeXorY.
Have a read of Chapter 13, Defining and Managing TN XML Document Types, in the Trading Networks Administration Guide, which describes how to use attribute transformation services (both built-in and custom). Unfortunately it doesn’t really tell you how to build your own.
I’ve actually created a custom transformation service in my open-source TundraTN package (https://github.com/Permafrost/TundraTN) which you could use to transform your MessageType attribute to a boolean using a regular expression such as /[XY]/.
// Trading Networks string transformer which returns whether the given Trading Networks document (bizdoc)
// attribute value/s match the given regular expression pattern (arg).
// Refer to <http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html> for more information
// on regular expression use in Java.
Here’s how you would use this TundraTN regular expression matching transformer:
- Create a new STRING Document Attribute in TN called MessageTypeXorY (Edit the Document Type, and click the Document Attributes button on the Extract tab and then click the New… button to create a new Attribute)
- On the Document Type, extract the new attribute MessageTypeXorY with the same XPath query as the existing MessageType attribute
- Choose a Custom Transformation using the service TundraTN/tundra.tn.document.attribute.string:match on the new attribute
- Set the Custom Transformation input arg to a regular expresssion such as [XY] which returns true for the required values of MessageType
- Save the changes to the Document Type
- Edit the Extended Criteria on your Processing Rule, select the new MessageTypeXorY attribute and set it to be equal to ‘true’