Allan Chua
Allan Chua

Reputation: 10175

How to create a restriction for the result of two seperate elements in an XSD

I have the following XML

<Skills>
   <SkillID>1</SkillID>
   <SkillName>Catch</SkillName>
   <SkillPrefix>Re</SkillSuffix>
</SKills>

I am tasked to create a XSD file that would validate the length of the concatenated value of SkillName and SkillPrefix, the problem is I don't know if it is possible to check the total length of SkillName and SkillPrefix with a single restriction in XSD. Can somebody please help me on this thanks allot in advance.

Upvotes: 0

Views: 54

Answers (2)

Jordan Rodriguez
Jordan Rodriguez

Reputation: 49

I think this is better to be solved using XSLTs instead of a XSD. XSDs were dedicated for validations

Upvotes: 1

Petru Gardea
Petru Gardea

Reputation: 21638

Unfortunately, this isn't possible only with XSD; if there's a Schematron processor for your platform, use that in addition to your XSD; you can make an assertion that the sum of the length of your fields to meet certain criteria.

Upvotes: 1

Related Questions