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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:59:46+00:00 2026-06-01T18:59:46+00:00

As a reference, the most similar question already asked is: https://stackoverflow.com/questions/8667849/making-xforms-enforce-the-constraint-and-type-model-item-properties-only-when-fi The difference is

  • 0

As a reference, the most similar question already asked is: https://stackoverflow.com/questions/8667849/making-xforms-enforce-the-constraint-and-type-model-item-properties-only-when-fi The difference is that I cannot use the ‘relevant’ property since I do want the field to be visible and accessible.

I’m attempting to make an XForms form that has the following properties:

  1. It displays a text field named ‘information’. (for the example)
  2. This field must not be required, since it may not be necessary to enter data. (Or this data will be entered at a later time.)
  3. However, if data is entered in this field, it must adhere to the specified constraint.
  4. I cannot mark the field as not relevant since this would hide the field and some data may need to be entered in it.

The trouble now is that even though the field has no data in it, the constraint is still enforced (i.e. even though it is not marked as ‘required’).

I have taken a look at the XForms 1.1 specification, however it does not seem to describe how the properties ‘required’ and ‘constraint’ should interact.

The only option I see, is to add a part to the constraint such that an empty value is allowed.
e.g.:

. = ” or <actual-constraint>

However, I don’t like this. It feels like a workaround to add this to every such field.

Is there any other way to express that non-required fields should not need to match the constraint for that field? (Am I missing something?)

  • 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-01T18:59:47+00:00Added an answer on June 1, 2026 at 6:59 pm

    In XForms 1.1, required serves two purposes:

    1. mark the field as required (implementations can style controls to reflect this, e.g. with a “*”)
    2. take part in the validation process

    The latter is described in 4.3.3 The xforms-revalidate Event.

    An instance node is valid if and only if the following conditions hold:

    And one of the conditions is:

    the value is non-empty if the required model item property is true

    So it is a logical and between all aspects that impact validation.

    I can see how things could have been different, e.g. saying required="false()" could disable the rest of the validation. However that’s not the approach XForms is taking.

    Based on this there is nothing wrong checking for emptiness as part of the constraint.

    XForms 2.0 might add custom XPath functions, which might help with reuse of logic:

    <bind ref="information" constraint="my:constraint(.)">
    

    Also, if the constraint can be expressed with a type, you may be able to use one of the schema types in the XForms namespace, which allow empty values to be valid. For instance xforms:double considered the empty string and 42 to be valid values, but not gaga.

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

Sidebar

Related Questions

This is similar to this question . I asked Why? to the most popular
A similar question was asked and answered about a year ago, but was either
While this question asked something similar too, I'm interested in this from another angle.
This is in reference to the question asked at Create a Wordpress post with
I've got 2 monitors, and most of the time I've got some reference material
I've got a question about references between projects in a solution. Most of my
In reference to this answer to a Stack Overflow question : what is bench-testing
Someone asked the question I have a Visual Studio solution with many projects; how
My question somewhat overlaps with this and several other similar ones. Those have some
Most high-level languages (Python, Ruby, even Java) use pass-by reference. Obviously, we don't have

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.