Jump to content

pattern element in xsd


XOR001

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...