XOR001 Posted November 20, 2007 Share Posted November 20, 2007 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 More sharing options...
boen_robot Posted November 20, 2007 Share Posted November 20, 2007 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 More sharing options...
Synook Posted November 25, 2007 Share Posted November 25, 2007 You can also express that enumeration as a regular expression CHOICE[1-3] Link to comment Share on other sites More sharing options...
XOR001 Posted January 6, 2008 Author Share Posted January 6, 2008 ok thanks i'm checking with the company since now. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.