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

  • Home
  • SEARCH
  • 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 7076357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:17:18+00:00 2026-05-28T06:17:18+00:00

I had a problem with updating instance structure which contains repeating nodes. I wanted

  • 0

I had a problem with updating instance structure which contains repeating nodes. I wanted to use <action while=""/> construction but there was a problem using defined iterator inside this loop. Eventually it always used one value (first one) even though it was incremented. I resolved this problem by using xxforms:evaluate function thus I have:

xxforms:evaluate(concat('instance(''main'')/item[',xxforms:bind('idx'),']'))

instead of simpler

instance('main')/item[xxforms:bind('idx')]

Is this the only way to iterate across the list of nodes inside an action?

Example:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
  <head>
    <title>Test</title>
    <xf:model id="model">
      <xf:instance id="main" xmlns="">
        <main>
          <item>
            <name />
          </item>
          <item>
            <name />
          </item>
          <item>
            <name />
          </item>
        </main>
      </xf:instance>
      <xf:instance id="temp" xmlns="">
        <main>
          <idx></idx>
          <value>inserted node</value>
        </main>
      </xf:instance>

      <xf:bind id="idx" nodeset="instance('temp')/idx" type="xsd:integer" />
    </xf:model>
  </head>

   <body>
    <xf:trigger>
      <xf:label>Not working as expected</xf:label>
      <xf:action ev:event="DOMActivate">
        <xf:setvalue bind="idx" value="1" />
        <xf:action while="number(xxforms:bind('idx')) le count(instance('main')/item)">
          <xf:insert context="instance('main')/item[xxforms:bind('idx')]" nodeset="name" position="after" origin="instance('temp')/value" if="not(exists(value))" />
          <xf:setvalue bind="idx" value=". + 1" />
        </xf:action>
      </xf:action>
    </xf:trigger>

    <xf:trigger>
      <xf:label>Working as expected but too complicated</xf:label>
      <xf:action ev:event="DOMActivate">
        <xf:setvalue bind="idx" value="1" />
        <xf:action while="number(xxforms:bind('idx')) le count(instance('main')/item)">
          <xf:insert context="xxforms:evaluate(concat('instance(''main'')/item[',xxforms:bind('idx'),']'))" nodeset="name" position="after" origin="instance('temp')/value" if="not(exists(value))" />
          <xf:setvalue bind="idx" value=". + 1" />
        </xf:action>
      </xf:action>
    </xf:trigger>
    <widget:xforms-instance-inspector id="orbeon-xforms-inspector" xmlns:widget="http://orbeon.org/oxf/xml/widget" />
   </body>
</html>

So I get as a result (first trigger):

<main>
  <item>
    <name/>
    <value>inserted node</value>
  </item>
  <item>
    <name/>
  </item>
  <item>
    <name/>
  </item>
</main>

but expected (second trigger):

<main>
  <item>
    <name/>
    <value>inserted node</value>
  </item>
  <item>
    <name/>
    <value>inserted node</value>
  </item>
  <item>
    <name/>
    <value>inserted node</value>
  </item>
</main>
  • 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-05-28T06:17:19+00:00Added an answer on May 28, 2026 at 6:17 am

    Here is a version that works:

    <xf:action ev:event="DOMActivate">
        <xf:setvalue bind="idx" value="1"/>
        <xf:action while="xs:integer(xxforms:bind('idx')) le count(instance('main')/item)">
            <xf:insert context="instance('main')/item[xs:integer(xxforms:bind('idx'))]" nodeset="name" position="after"
                       origin="instance('temp')/value" if="not(exists(value))"/>
            <xf:setvalue bind="idx" value=". + 1"/>
        </xf:action>
    </xf:action>
    

    The issue is that xxforms:bind('idx') returns an untyped value, even through you specified xsd:integer. XForms currently doesn’t specify that type annotations on binds must cause a typed value to be provided (see these notes on type annotation). This means that in this case, the predicate value is not a number (XPath has both boolean and numeric predicates, and this is often a source of confusion). In order to make it a numeric predicate, converting to a number is needed.

    Here I use xs:integer as number is kind of an XPath 1 legacy function, and it returns an xs:double while the count() function returns an xs:integer).

    There is much simpler solution with xxforms:iterate:

    <xf:action ev:event="DOMActivate" xxforms:iterate="item">
        <xf:insert if="not(exists(value))"
                   context="."
                   nodeset="name"
                   origin="instance('temp')/value"/>
    </xf:action>
    

    iterate is currently an extension, but XForms 2 will add it.

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

Sidebar

Related Questions

I had a problem in site map path I had navigation bar which take
I had a json parsing problem updating my app from prototype 1.6.1 to 1.7.0
I had a problem when updating a table in SQL Server CE on Windows
I had a problem that was partially solved. To explain it quickly : I
I had a problem with committing changes after merging two branches of my project
I had this problem before and can't for life of me remember how to
I had no problem at all running the following code on a local server,
I had a problem where I had a series of overlapping CATransition / CAAnimation
I had a problem with set not working in a batch file; it took
I had this problem some time ago and I gave up but lately it

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.