XML, XSD Enforce element widths

I need to write an XSD, based on which my clients will generate an XML file(version 1.0) which I process an store in database.
I have come across following potential problems.
1. I need to ensure that for some elements, value cannot exceed beyond certain characters, due to database column width limitations.
2. For decimal type, especially % elements, I need value between 0.0000(0%) and 1.0000(100%) without % sign.
How can I enforce this in XSD file.
Also, is there a Windows tools(freeware) which helps me in writing XSD and also validating XML? I am using Visual C++ currently.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1. To create a string of a limited length then create a custom type in XSD like:

<xs:simpleType name="50CharString">
    <xs:restriction base="xs:string">
      <xs:maxLength value="50" />
You can even represent it with a regex if needed.

<xs:simpleType name="percentage">
    <xs:restriction base="xs:decimal">
      <xs:min-Inclusive value=" 0.0000" />
      <xs:max-Inclusive value="1.0000" />

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VakilsDeveloperAuthor Commented:
Can you give me regex example for string?
Maybe something like this: (not tested)

<xs:simpleType name="50CharString">
    <xs:restriction base="xs:string">
      <xs:pattern value=".{50}"/>

The dot meaning any character matched {50} times.
VakilsDeveloperAuthor Commented:
Works. Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.