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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:34:51+00:00 2026-05-10T22:34:51+00:00

I am in the process of creating an XML Schema and one of my

  • 0

I am in the process of creating an XML Schema and one of my values is a year. As such, I’d like to ensure that all values have exactly 4 characters. To do so, I am using the following syntax:

<xs:element name='publish_year' maxOccurs='1'>   <xs:simpleType>     <xs:restriction base='xs:positiveInteger'>       <xs:totalDigits value='4'/>     </xs:restriction>   </xs:simpleType>                                       </xs:element> 

If I’m understanding ‘totalDigits’ correctly, someone could pass in a ‘publish_year’ value of ‘2008’ or ‘200’. Both would be valid. As such, how can I structure my XSD to ensure 4 digits are required? At first blush, I’m guessing I’d use a regex, but I’d like to know if I’m overlooking something that’s already baked in (like ‘totalDigits’)

UPDATE:

I went with the following solution. It may be overkill, but it gets the point across:

<xs:simpleType>     <xs:restriction base='xs:positiveInteger'>         <xs:totalDigits value='4' fixed='true'/>         <xs:minInclusive value='1900'/>         <xs:pattern value='^([1][9]\d\d|[2]\d\d\d)$'/>     </xs:restriction> </xs:simpleType> 
  • 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. 2026-05-10T22:34:51+00:00Added an answer on May 10, 2026 at 10:34 pm

    How about a plage of value as an additional restriction ?

    (minInclusive – maxInclusive)

    For instance ?

    <xs:minInclusive value='1900'/> et <xs:maxInclusive value='2008'/> 

    But to get back to the totalDigits constraint, why do you not set the fixed attribute to true ?

    If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for totalDigits other than {value}.

    <xs:totalDigits value='4' fixed='true' /> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Local temporary tables are destroyed when you close your connection… May 11, 2026 at 10:14 am
  • added an answer Yes, avoiding recursion is a good thing on all embedded… May 11, 2026 at 10:14 am
  • added an answer Remove the OpenAL framework you added. Go to one of… May 11, 2026 at 10:14 am

Related Questions

I am in the process of creating an XML Schema and one of my
I am currently in the process of creating my own blog and I have
I am in the process of beginning work on several ASP.NET custom controls. I
I am in the process of writing a Bluetooth scanner that locates and identifies
I am in the process of developing a web application that consists visually of
I am in the process of moving from VSS to SVN and I'm not
I am in the process of designing a daily build routine for my project.
I am in the process of writing a text editor. After looking at other
I am in the process of researching/comparing CXF and Spring-WS for web services? I
I am in the process of setting up CruiseControl.NET. The problem I am having

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.