xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chetan Chudasama <cche...@nms.fnc.fujitsu.com>
Subject Re: Schema question
Date Tue, 08 May 2001 21:21:02 GMT
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: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org

--
Chetan Chudasama
Fujitsu Network Communications
Call: (408) 895 1707
Email: cchetan@nms.fnc.fujitsu.com




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Mime
View raw message