9 Replies Latest reply on Jun 21, 2018 6:30 AM by Martien van den Akker

    How do I assert a JAXBElement in Business Rules?

    heidibuelow

      My Input and Output Fact schema when brought into Rules gets its strings converted to JAXBElement.  Now I want to set the result and can't make it work.  I am working around this by changing my Fact schema so that the strings are not converted but it would be nice to have it in one place here in the rule itself.

       

      This is the reason the schema strings are converted:

      https://docs.oracle.com/cd/E28271_01/user.1111/e10228/faq.htm#BGBJIDDH

       

      I have an idea to create a Rule function called MakeJAXBString and do the work in the function to return me a JAXBElement given a String.  I can't get the syntax right.

       

      I see the constructor here:

      https://docs.oracle.com/javase/6/docs/api/javax/xml/bind/JAXBElement.html

      public JAXBElement(QName name, Class<T> declaredType, Class scope, T value)

      Construct an xml element instance.

       

      Parameters:
      name - Java binding of xml element tag name
      declaredType - Java binding of xml element declaration's type
      scope - Java binding of scope of xml element declaration. Passing null is the same as passing GlobalScope.class
      value - Java instance representing xml element's value.

      And my MakeJAXBString Rules function looks something like:

      Arg: inputString

      Returns: JAXBElement

      Assign new JAXBElement myjaxb = new JAXBElement("xsd:string", java.lang.String, null, "")

      Assign new myjaxb.value = (Object)inputString

      return myjaxb

       

      But the JAXBElement constructor is wrong every which way I try it.

       

      Eventually I want to assert the output fact something like this in the Decision Table. 

      Condition: GetString(inputJaxb) = "Current control"

      Action: assert new ControlType(controlStr: JAXBElement)

      Value: MakeJAXBString("New control")