Using BRE to check for Empty, Nil and Existence RRS feed

  • Question

  • Hi

    I'm using the BRE to perform some validation on an incomming message.  This is appropriate to my needs as the validation rules may need to be updated at short notice.

    The incomming message would be something like this:

     <product>Power Drill</product>

    I would like to set validationNote to "Missing Product Value" if product meets any of these conditions:

     - An empty string
     - Nil
     - Missing from the XML message
    The part I'm struggling on is creating the vocabulary and rule to catch all three conditions.  I've tied various Xpath field and selector settings but with not a great deal of success.

    Any guidance would be greatly appreciated.


    Wednesday, April 27, 2016 9:32 AM


  • Are you using a .NET helper class method as the vocabulary for this? It should be fairly simple.

    Add a reference to Microsoft.RuleEngine in your helper class.

    The C# method that does the validation can have a signature, like-

    public static void SetValidationData(TypedXmlDocument envelope)

    // treat this TypedXmlDocument's Document property just like System.Xml.XmlDocument within your code

    Within this method, write standard System.Xml code that can perform your 3 tasks.

    See a sample here , that evaluates a XPATH expression and returns the value of an XML element.

    If you get an empty/null string from the XPATH call, you can set the string "Missing Product Value" within the <validationNote> in the TypedXmlDocument parameter that you received.

    Thanks Arindam

    Wednesday, April 27, 2016 9:51 AM