This article provides suggestions to some common scripting problems.  



I am getting an error when trying to run a <Log> using a path expression with a Context (3rd entry in below example). 

<Text>___________Requirements Related to Production #{Name} --- #{? /back::GateToReq/back::FTAtoTop/FTAtoProdReq.Select(Name)}</Text> 

<Log>___________Requirements Related to Production #{Name} WO Context --- #{? /back::GateToReq/back::FTAtoTop/FTAtoProdReq.Select(Name)}</Log>

<Log>___________Requirements Related to Production #{Name} W Context --- #{? Context:/back::GateToReq/back::FTAtoTop/FTAtoProdReq.Select(Name)}</Log>


The <Text> tag works fine.

First <Log> returns an empty list.

Second log (with Context:) crashes with parsing error, but the document execution is continued.


Error message

:

Adding Section 40

___________Requirements Related to Production ABC1 W Context --- Error parsing expression:

 Context:/back::GateToRequ/back::FTAtoTop/FTAtoProdRequ.Select(Name)

Compile error: Pos(1:9)

Syntax Error(-23): ":" found

but [(EOF)] expected

--> Parsing prematurely halted due to unsolveable error at (1:9)

Adding Section 41

:


Resolution:

You must declare a variable first. Example: 
<Variable name="ReqRelatedToProd" as="Items"  select="Context:/back::GateToReq/back::FTAtoTop/FTAtoProdReq) "/>

<Log>___________Requirements Related to Production #{Name} W Context --- #{? $ReqRelatedToProd .Select(Name)}</Log>

In my graph configuration, the variables in the template are not found.

<Graph>
 <Layout name="incrementalHierarchical">
  <Setting name="layoutOrientation" value="bottomToTop"/>
 </Layout>
 <NodeGroups>
  <NodeGroup name="CRQ" caption="Stakeholder Requirement"/>
 </NodeGroups>
 <NodeStyles>
  <NodeStyle name="stakeReq" borderThickness="2" fillColor="#87CEFA" fillColor2="#FFFFFF" legendLabel="Stakeholder Requirement"/>
 </NodeStyles>
 <EdgeStyles>
  <EdgeStyle name="satis" color="Black" lineType="solid" fromArrowType="default" legendLabel="Trace"/>
  <EdgeStyle name="versionMismatch" color="Red" lineType="dash" fromArrowType="default" legendLabel="Trace With VersionMismatch"/>
 </EdgeStyles>
 
 <Variable name="baseline" as="String" select="VersionNumber"/>
 <Variable name="baselineItem" as="Item" select="."/>
 
...

 <Template name="reverseStakeReq">
  <ForEach select="/back::FGHI/JKLM">
   <Edge from="$baselineItem" to="." style="#{? if $baseline = $currentItem then 'satis' else 'versionMismatch'" caption="'Is satisfied by'"/>
   <Node style="stakeReq" group="CRQ" caption="#{Name}#{?NewLine}Version:#{Version}#{?NewLine}Status:#{Status}#{?NewLine}Safety Relevant: #{@ABCDE}"/>
  </ForEach>
 </Template>
 
</Graph>

Resolution:

When using <Template/>, which is different from <ItemTemplate/>, one has no access to variables outside of the <Template/> itself. To get access to variables, these should be sent to the template as ingoing arguments when calling on the specific template using <WithParam/>.


Example: 

<ApplyTemplate name="reverseStakeReq">
   <WithParam name="baseline" select="$baseline"/>
</ApplyTemplate>

Then they need to be declared in the template itself:

<Template name="reverseStakeReq">
   <Parameter name="baseline" as="[Item]"/>
</Template>