Return initial value or most recent occurance with XPath then run operator

worldcom

New Member
I have the following XPath 1.0 expression in MS InfoPath (I will post accompanying XML):\[code\]//my:Value_Modifier_Group[1=count(following-sibling::my:Value_Modifier_Group)]//my:Modified_Start_Value[(text())] | //my:Start_Value[text() and not(//my:Value_Modifier_Group[1=count(following-sibling::my:Value_Modifier_Group)]//my:Modified_Start_Value[(text()])]\[/code\]If there is an initial value and no "Modified Value" yet then the initial value is returned. If a modified value is present then it is returned.I need to return that value and then perform the following operations on it:\[code\]number(//my:Value_Modifier_Group[1=count(following-sibling::my:Value_Modifier_Group)]//my:Modfied_Start_Value) + number(//my:Value_Modifier_Group[0=count(following-sibling::my:Value_Modifier_Group)]//my:Start_Value_Increase) - number(//my:Value_Modifier_Group[0=count(following-sibling::my:Value_Modifier_Group)]//my:Start_Value_Decrease)\[/code\]This operation adds or subtracts an increase/decrease value. The problem is that this expression returns a NaN if no \[code\]Modified_Start_Value\[/code\] is present. Works great otherwise.I need to team both of these expressions together into a single XPath expression.
  • If \[code\]Modified_Start_Value\[/code\] has a preceding value, use that in operations
  • If \[code\]Modified_Start_Value\[/code\] does not have a preceding value then use \[code\]Start_Value\[/code\] in operations instead
  • It is important that I always use the "preceding" value because the preceding value is fixed. It acts as a reference point or starting point.
Here is a sample of the XML I am using:\[code\]<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.2" productVersion="14.0.0" PIVersion="1.0.0.0" href="file:///C:\Documents%20and%20Settings\Chris\Local%20Settings\Application%20Data\Microsoft\InfoPath\Designer3\ef41a19775b4ce0\manifest.xsf" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.3"?><my:myFields xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2012-09-19T13:28:35" xml:lang="en-us"><my:Start_Value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">6</my:Start_Value><my:Main_Group> <my:Value_Modifier_Group> <my:Modified_Start_Value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">6</my:Modified_Start_Value> <my:Start_Value_Increase>0</my:Start_Value_Increase> <my:Start_Value_Decrease>0</my:Start_Value_Decrease> </my:Value_Modifier_Group><my:Value_Modifier_Group> <my:Modified_Start_Value>6</my:Modified_Start_Value> <my:Start_Value_Increase>0</my:Start_Value_Increase> <my:Start_Value_Decrease>0</my:Start_Value_Decrease></my:Value_Modifier_Group></my:Main_Group></my:myFields>\[/code\]I hope this question isn't too hastily put together! Busy day today...
 
Back
Top