Hi Benson, See if the following schema helps you:
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified"> <xsd:element name="Root"> <xsd:complexType> <xsd:sequence> <xsd:element name="Group"> <xsd:complexType> <xsd:sequence> <xsd:element name="Id"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Invoice"/> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="value"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element name="Group"> <xsd:complexType> <xsd:sequence> <xsd:element name="Id"/> <xsd:element name="value"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:choice> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Cheers, Chetan Benson Cheng wrote: > Hi, > > I hava a schema question. I need write a schema to validate the following > sample XML file, the key is that at least one <Group> node is exist, and at > least one of its <Id> is the "Invoice" value, other <Group>/<Id> could be > anything. I think I need use "Choice", but not sure how to do it, any hint > will be help. > > <?xml version="1.0" encoding="UTF-8" ?> > <Root> > <Group> > <Id>Invoice</Id> > <value>123456</value> > </Group> > <Group> > <Id>Anything1</Id> > <value>99999</value> > </Group> > <Group> > <Id>Anything2</Id> > <value>888888</value> > </Group> > </Root> > > Thanks, > Benson. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Chetan Chudasama Fujitsu Network Communications Call: (408) 895 1707 Email: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
