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 7079823
In Process

The Archive Base Latest Questions

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

I’ve got a problem and hope it’s only my lack of experience in XForms.

  • 0

I’ve got a problem and hope it’s only my lack of experience in XForms. I need to create checkbox item for data that is defined as an enumeration ‘Yes’/’No’. Basically it’s just boolean value but with another pair of values. What I’ve already been able to do is something that basically works but need extra data node in model:

<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
    xmlns:f="http://orbeon.org/oxf/xml/formatting"
    xmlns:xhtml="http://www.w3.org/1999/xhtml"
    xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
    xmlns:ev="http://www.w3.org/2001/xml-events"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    >

    <xhtml:head>
        <xforms:model xmlns:xforms="http://www.w3.org/2002/xforms"
                xmlns:xs="http://www.w3.org/2001/XMLSchema" id="main-model">
          <xforms:instance id="instance">
            <main>
              <Boolean>true</Boolean>
              <YesNo>Yes</YesNo>
            </main>
          </xforms:instance>
          <xforms:bind ref="Boolean" type="xsd:boolean" />
          <xforms:bind ref="YesNo" constraint=". = 'Yes' or . = 'No'" />
        </xforms:model>
    </xhtml:head>
    <xhtml:body>
      <xforms:input ref="instance('instance')/Boolean">
        <xforms:label>Boolean: </xforms:label>
        <xforms:action ev:event="xforms-value-changed">
          <xforms:setvalue ref="instance('instance')/YesNo" value="if ( instance('instance')/Boolean = 'true' ) then 'Yes' else 'No'" />
        </xforms:action>
      </xforms:input>
      <br/>
      <xforms:output ref="instance('instance')/Boolean">
        <xforms:label>Boolean:</xforms:label>
      </xforms:output>
      <br/>
      <br/>
      <xforms:select ref="instance('instance')/YesNo" appearance="full">
        <xforms:label>Yes/No: </xforms:label>
        <xforms:item>
          <xforms:label></xforms:label>
          <xforms:value>Yes</xforms:value>
        </xforms:item>
        <xforms:action ev:event="xforms-value-changed">
          <xforms:setvalue ref="instance('instance')/YesNo" value="if ( instance('instance')/YesNo = 'Yes' ) then 'Yes' else 'No'" />
        </xforms:action>
      </xforms:select>
      <br/>
      <xforms:output ref="instance('instance')/YesNo">
        <xforms:label>Yes/No:</xforms:label>
      </xforms:output>
    </xhtml:body>
</xhtml:html>

This example contains two possible solutions:
First is standard boolean checkbox bound to boolean instance node with an action that set ‘Yes’/’No’ value for the second node. This solution works well but requires second data node which I cannot create due to schema (in the example above I could generally create second instance to store this value but in real project these checkboxes are in repeat block and I would have to create extra table of values for this which seems to be to much complicated),
Second is select item with one and only value ‘Yes’ and action that tries to set ‘No’ value when empty value is set (unselected item). Unfortunatelly when this item is deselected it’s unable to select it again (deselects automatically). Has any of you solution for such an issue?

Thanks in advance

  • 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:43:09+00:00Added an answer on May 28, 2026 at 6:43 am

    Hope this solves your problem..

    <xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:f="http://orbeon.org/oxf/xml/formatting"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        >
    
        <xhtml:head>
            <xforms:model xmlns:xforms="http://www.w3.org/2002/xforms"
                    xmlns:xs="http://www.w3.org/2001/XMLSchema" id="main-model">
              <xforms:instance id="instance">
                <main>
                  <Boolean value="true">Yes</Boolean>
                </main>
              </xforms:instance>
              <xforms:bind ref="Boolean/@value" type="xforms:boolean" readonly="false()" />
              <xforms:bind ref="Boolean" calculate="if(@value=true()) then 'Yes' else 'No'" readonly="false()" />
            </xforms:model>
        </xhtml:head>
        <xhtml:body>
          <xforms:input ref="instance('instance')/Boolean/@value">
            <xforms:label>Boolean: </xforms:label>
          </xforms:input>
          <br/>
          <xforms:output ref="instance('instance')/Boolean">
            <xforms:label>Boolean:</xforms:label>
          </xforms:output>
          <br/>
          <xforms:output ref="instance('instance')/Boolean/@value">
            <xforms:label>Boolean/@value:</xforms:label>
          </xforms:output>
          <br/>
          <br/>
    
    
        </xhtml:body>
    </xhtml:html>
    

    In case if you are not allowed to use attributes to your xml node, then have the boolean values while user working on the form. On submit event, you can set the boolean values to Yes or No and push the data to external system.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.