Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:57:34+00:00 2026-06-11T14:57:34+00:00

I have the following XPath 1.0 expression in MS InfoPath (I will post accompanying

  • 0

I have the following XPath 1.0 expression in MS InfoPath (I will post accompanying XML):

//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()])]

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:

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)

This operation adds or subtracts an increase/decrease value. The problem is that this expression returns a NaN if no Modified_Start_Value is present. Works great otherwise.

I need to team both of these expressions together into a single XPath expression.

  • If Modified_Start_Value has a preceding value, use that in operations
  • If Modified_Start_Value does not have a preceding value then use Start_Value 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:

<?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>

I hope this question isn’t too hastily put together! Busy day today…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:57:36+00:00Added an answer on June 11, 2026 at 2:57 pm

    Ok, I am going to self answer this question as I just figured it out.

    The key is to combine the XPath expressions by placing the value from the first expression into a node and then referencing that node in the second expression.

    It seems that the pipe command | does not play well with other operators.

    The following expression returns values in the following way:

    • //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()])]
    • If no preceding Modified_Start_Value is available before the first Modified_Start_Value node the expressions defaults to the initial value.
    • In this way you are guaranteed the most recent valid Start_Value or Modified_Start_Value

    This value of this expression is then put into a node titled StartVModStart. The XPath for this node is then put into the evaluating expression:

    ../../../my:StartVModStart + number(/descendant-or-self::node()/my:Value_Modifier_Group[0 = count(following-sibling::my:Value_Modifier_Group)]//my:Start_Value_Increase) - number(/descendant-or-self::node()/my:Value_Modifier_Group[0 = count(following-sibling::my:Value_Modifier_Group)]//my:Start_Value_Decrease)

    • This expression uses “the most recent” value and then adds or subtracts the changes

    In this way one can keep a “running sum” through the course of document, starting in an initial node and moving all the way through repeating nodes.

    This question seems highly convoluted, so forgive me if both my question and answer do not seem clear. As I reach for more complex functionality the required XPath expressions become more and more complex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following XPath expression: //*[@name='outputFormat']/ows:Value I would like to make it case
I have the following Java code working with XPath to get data from XML
I have the following XPath expression to get all textNodes within a element. var
I have the following xpath query which seems to be working but I just
I have the following XPATH line: //det[@nItem=1]/prod/cProd That successfully selects the desired node using
I have the following html and like to know how to use xpath to
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
I have the following xml snippet <ZMARA01 SEGMENT=1> <CHARACTERISTICS_01>X,001,COLOR_ATTRIBUTE_FR,BRUN ÉCORCE,TMBR,French C</CHARACTERISTICS_01> <CHARACTERISTICS_02>X,001,COLOR_ATTRIBUTE,Timber Brown,TMBR,Color Attr</CHARACTERISTICS_02>
I have the following XML: <ns:response xmlns:ns=http://example.com xmlns:ax=http://example.com/xsd > <ns:return type=mytype> <ax:roleID>1</ax:roleID> <ax:roleName>ADM</ax:roleName> </ns:return>
I have the following code: // xpath evaluates to net.sf.saxon.xpath.XPathEvaluator XPath xpath = XPathFactory.newInstance().newXPath();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.