XML Schema - String List

The element must be of the type of "list of lines", and there may be 0or more of the appearance of this type of information. So what I did:

<xs:element name="xxx" type="ooo" />

<xs:simpleType name="ooo">
   <xs:list itemType="xs:string" />
</xs:simpleType>

I believe that is correct, but

where do i put here minOccurand maxOccur?

+9
source share
3 answers

Your question, unfortunately, is unclear, because it can mean several things.

One possible interpretation is that you want the element "xxx" to occur between 0 and x times. This is done by determining the sequence inside the root element.

<xs:simpleType name="ooo">
  <xs:restriction base="xs:string" />
</xs:simpleType>

<xs:element name="root">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="xxx" type="ooo" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

minOccurs maxOccurs , XML . , , .

, , "xxx" , . , "root" "xxx", - "ooo"

<xs:simpleType name="ooo">
  <xs:restriction base="xs:string" />
</xs:simpleType>

<xs:element name="xxx">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="xxx-child" type="ooo" maxOccurs="unbounded" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>
</xs:element>

"" , , , . XSD , , , .

<xs:simpleType name="ooo">
  <xs:list itemType="xs:string" />
</xs:simpleType>

<xs:element name="xxx" type="ooo" />

XML :

<xxx>item1 item2 item3 item4 item5</xxx>

XML - , . , xs:string, , .

, , , , , "xxx" "xxx-child", , .

<xs:complexType name="ooo">
  <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element name="child" type="xs:string" />
  </xs:sequence>
</xs:complexType>

<xs:element name="xxx" type="ooo" />

XML :

<?xml version="1.0" encoding="utf-8"?>
<xxx>
  <child></child>
  <child></child>
  <child></child>
</xxx>

, , minOccurs="0" maxOccurs="unbounded" <xs:sequence> "child". , XML. 2 , :

<xs:complexType name="ooo">
  <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element name="child1" type="xs:string" />
    <xs:element name="child2" type="xs:string" />
  </xs:sequence>
</xs:complexType>

XML ( child1 follow by child2 x ):

<?xml version="1.0" encoding="utf-8"?>
<xxx>
  <child1></child1>
  <child2></child2>
  <child1></child1>
  <child2></child2>
  <child1></child1>
  <child2></child2>
</xxx>

as

<xs:complexType name="ooo">
  <xs:sequence>
    <xs:element name="child1" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
    <xs:element name="child2" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
  </xs:sequence>
</xs:complexType>

XML (child1 x , ​​ child2, y time):

<?xml version="1.0" encoding="utf-8"?>
<xxx>
  <child1></child1>
  <child1></child1>
  <child2></child2>
  <child2></child2>
  <child2></child2>
  <child2></child2>
  <child2></child2>
</xxx>
+26

, , :

<xs:complexType>
    <xs:sequence>
        <xs:element name="stringList" block="extension"
            minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
    </xs:sequence>
</xs:complexType>

, ( )

List<String> stringList;
0

Here is an example of the code I found that might help you:

<xs:element name="person">
<xs:complexType>
        <xs:sequence>
          <xs:element name="full_name" type="xs:string"/>
          <xs:element name="child_name" type="xs:string"
          maxOccurs="10" minOccurs="0"/>
        </xs:sequence>
</xs:complexType>
</xs:element>
-1
source

All Articles