Jump to content

pattern element in xsd


XOR001
 Share

Recommended Posts

Hi,i'm pretty new to xml and i got problems validating some file I wrote through an xsd that has been furnished by some third part company.Here is my concern about the code :<xs:element name="ChooseOne"><xs:simpleType><xs:restriction base="xs:string"><xs:pattern value=""/><xs:enumeration value="CHOICE1"/><xs:enumeration value="CHOICE2"/><xs:enumeration value="CHOICE3"/></xs:restriction></xs:simpleType></xs:element>so when I write at this level <ChooseOne>CHOICE1</ChooseOne> I got an error while trying to validate the xml file whether with XMLfox or XMLSpy saying the value for ChooseOne is incorrect (fun is that in XMLSpy when I edit the xml it is giving me CHOICE1,CHOICE2 or CHOICE3 in a scroll menu).It looks like the problme comes from that line that I don t understand :<xs:pattern value=""/>When I delete it the validation is working properly (if I put something else than CHOICE1,2 or 3 it is giving an error).Can any1 help me ?Thanks

Link to comment
Share on other sites

The pattern is a regular expression the value must match.The regular expression you have shows the value must be empty. And yet you allow those values. What you need to do is remove the pattern. If you want to allow the element to have an empty value, use "" as an enumeration instead.

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...