Menu

evaluateVariable

bamanuel
2011-01-13
2012-09-22
  • bamanuel

    bamanuel - 2011-01-13

    How do you use the evaluateVariable function? Can anyone provide a sample on
    how a local/global parameter is used?

     
  • Martin Roberts

    Martin Roberts - 2011-01-13

    The way this is used is to enable you to get a variable re-evaluated when the
    xpath specified in a local parameter is relative. You simply use the
    evaluateVariable($variableName) If this fails try without the $.

    The idea is for when you have repeating patterns such as orderlines and you
    want a variable to be set that say should contain the orderLineID. So when you
    come to the orderline you assocciate a rule with the OrderLine element and get
    the value of the variable reset for this new Orderline.

    I hope this helps.

     
  • bamanuel

    bamanuel - 2011-01-14

    It returns an error "Variable has not been declared." The variable keeps the
    first evaluated xpath expression value. Has it worked for you? Perhaps it is a
    bug.

     
  • drrwebber

    drrwebber - 2011-01-14

    You declare the variable in the header. Use the Parameters tab at the bottom
    of the screen to declare the variable you are referencing. Here's an example
    of what gets added to header.

    If you were already doing this - and still getting error - please could you
    post simple example template and XML so we can debug?

    <as:Header> <as:Description>Example template header</as:Description>
    <as:Owner>To be Completed</as:Owner> <as:Version>0.1</as:Version>
    <as:DateTime>2011-01-12T15:42:32</as:DateTime> <as:Parameters> <as:Parameter name="CheckThis" values="'1'|'2'|'3'" xpath="\\Organization\\@Usage" use="local"/> </as:Parameters> </as:Header>

     
  • bamanuel

    bamanuel - 2011-01-14

    The goal is to check Value1 == Value2 in each Node.

    <Root>
      <Node>
        <Value1>1</Value1>
        <Value2>1</Value2>
      </Node>
      <Node>
        <Value1>2</Value1>
        <Value2>2</Value2>
      </Node>
    </Root>
    
    <as:CAM
     xmlns:as="[url]http://www.oasis-open.org/committees/cam[/url]"
     xmlns:camed="[url]http://jcam.org.uk/editor[/url]"
     xmlns:xml="[url]http://www.w3.org/XML/1998/namespace[/url]"
     xmlns:xs="[url]http://www.w3.org/2001/XMLSchema[/url]" CAMlevel="1" version="1.1">
      <as:Header>
        <as:Description>No Description</as:Description>
        <as:Owner>Not Set</as:Owner>
        <as:Version>0.1</as:Version>
        <as:DateTime>2011-01-14T17:40:23</as:DateTime>
        <as:Parameters>
          <as:Parameter name="Value1" default="1" xpath="//Node/Value1" use="local" />
        </as:Parameters>
      </as:Header>
      <as:AssemblyStructure>
        <as:Structure ID="NewFile" taxonomy="XML" reference="">
          <Root>
            <Node>
              <Value1>%1%</Value1>
              <Value2>%1%</Value2>
            </Node>
          </Root>
        </as:Structure>
      </as:AssemblyStructure>
      <as:BusinessUseContext>
        <as:Rules>
          <as:default>
            <as:context>
              <as:constraint action="evaluateVariable(/Root/Node/Value1,Value1)" />
              <as:constraint action="setValue(//Node/Value2,$Value1)" />
              <as:constraint action="makeRepeatable(/Root/Node)" />
            </as:context>
          </as:default>
        </as:Rules>
      </as:BusinessUseContext>
    </as:CAM>
    
     
  • drrwebber

    drrwebber - 2011-01-15

    Thanks for the example - seems like there's three things happening at once
    here. We'll break this down and make some examples illustrating each part. The
    setValue should be conditional I believe - based on no value existing in
    node2. Also XPath expressions does allow direct equals comparison. Will post
    something back shortly...

     
  • drrwebber

    drrwebber - 2011-01-17

    I believe this does what you were trying to do above.

    <as:CAM
     xmlns:as="[url]http://www.oasis-open.org/committees/cam[/url]"
     xmlns:camed="[url]http://jcam.org.uk/editor[/url]"
     xmlns:xml="[url]http://www.w3.org/XML/1998/namespace[/url]"
     xmlns:xs="[url]http://www.w3.org/2001/XMLSchema[/url]" CAMlevel="1" version="1.1">
      <as:Header>
        <as:Description>No Description</as:Description>
        <as:Owner>Not Set</as:Owner>
        <as:Version>0.1</as:Version>
        <as:DateTime>2011-01-14T17:40:23</as:DateTime>
      </as:Header>
      <as:AssemblyStructure>
        <as:Structure ID="NewFile" taxonomy="XML" reference="">
          <Root>
            <Node>
              <Value1>%1%</Value1>
              <Value2>%1%</Value2>
            </Node>
          </Root>
        </as:Structure>
      </as:AssemblyStructure>
      <as:BusinessUseContext>
        <as:Rules>
          <as:default>
            <as:context>
              <as:constraint action="makeRepeatable(/Root/Node)" />
              <as:constraint condition="not( ./Value1 = ./Value2 )" action="printMessage(//Root/Node,Mismatched values!)" />
            </as:context>
          </as:default>
        </as:Rules>
      </as:BusinessUseContext>
    </as:CAM>
    
     
  • drrwebber

    drrwebber - 2011-01-17

    As a foot note to this - the evaluateVariable and Parameter declarations are
    really for use as a shorthand for something globally referenced in a
    conditional expression. So say I need to check that one group of partners
    messages - contain a specific code value. The partners all have ID numbers
    beginning with BANK say - so I could setup a parameter that checks begins-
    with(ID,'BANK') - and then whenever I need to check that I can use the
    shorthand parameter name.

     

Log in to post a comment.