XML, XSD Enforce element widths

Hi,
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.
Thanks.
VakilsDeveloperAsked:
Who is Participating?
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.

gurpsbassiCommented:
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" />
    </xs:restriction>
  </xs:simpleType>
You can even represent it with a regex if needed.

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

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:
Thanks!
Can you give me regex example for string?
0
gurpsbassiCommented:
Maybe something like this: (not tested)

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

The dot meaning any character matched {50} times.
0
VakilsDeveloperAuthor Commented:
Works. Thanks!
0
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
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.