XSD ਕੰਪਲੈਕਸ ਟਾਈਪ ਇੰਡੀਕੇਟਰ

ਸੂਚਕਾਂਕ ਰਾਹੀਂ ਅਸੀਂ ਦਸਤਾਵੇਜ਼ ਵਿੱਚ ਐਲੀਮੈਂਟ ਦੇ ਵਰਤੋਂ ਨੂੰ ਕੰਟਰੋਲ ਕਰ ਸਕਦੇ ਹਾਂ。

ਸੂਚਕਾਂਕ

ਸੱਤ ਸੂਚਕਾਂਕ ਹਨ:

Order ਸੂਚਕਾਂਕ:

  • All
  • Choice
  • Sequence

Occurrence ਸੂਚਕਾਂਕ:

  • maxOccurs
  • minOccurs

Group ਸੂਚਕਾਂਕ:

  • Group name
  • attributeGroup name

Order ਸੂਚਕਾਂਡ

Order ਸੂਚਕਾਂਡ ਤੰਤਰਾਂ ਦੀ ਕਿਸਮ ਨੂੰ ਨਿਰਧਾਰਿਤ ਕਰਦਾ ਹੈ。

All ਸੂਚਕਾਂਡ

<all> ਸੂਚਕਾਂਡ ਉਪ ਤੰਤਰਾਂ ਨੂੰ ਕਿਸੇ ਕਿਸਮ ਦੀ ਕਿਸਮ ਨਾਲ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋਣਾ ਨਿਰਧਾਰਿਤ ਕਰਦਾ ਹੈ, ਅਤੇ ਹਰੇਕ ਉਪ ਤੰਤਰ ਨੂੰ ਮਾਤਰ ਇੱਕ ਵਾਰ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋਣਾ ਚਾਹੀਦਾ ਹੈ:

<xs:element name="person">
  <xs:complexType>
    <xs:all>
      
      
    </xs:all>
  </xs:complexType>
</xs:element>

ਟਿੱਪਣੀ:ਜਦੋਂ <all> ਸੂਚਕਾਂਡ ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹਨ ਤਾਂ <minOccurs> ਨੂੰ 0 ਜਾਂ 1 ਸੈਟ ਕਰ ਸਕਦੇ ਹਨ ਅਤੇ ਮੈਕਸ ਓਕਰਸ ਸੂਚਕਾਂਡ ਨੂੰ ਮਾਤਰ 1 ਸੈਟ ਕਰ ਸਕਦੇ ਹਨ (ਜਿਸ ਵਿੱਚ minOccurs ਅਤੇ maxOccurs ਦੀ ਵਿਸਥਾਰ ਕੀਤੀ ਜਾਵੇਗੀ)。

Choice ਸੂਚਕਾਂਡ

<choice> ਸੂਚਕਾਂਡ ਕੋਈ ਉਪ ਤੰਤਰ ਜਾਂ ਦੂਜੇ ਉਪ ਤੰਤਰ (ਇੱਕ ਜਾਂ ਦੂਜਾ) ਪ੍ਰਕਾਸ਼ਿਤ ਹੋ ਸਕਦਾ ਹੈ:

<xs:element name="person">
  <xs:complexType>
    <xs:choice>
      <xs:element name="employee" type="employee"/>
      <xs:element name="member" type="member"/>
    </xs:choice>
  </xs:complexType>
</xs:element>

ਸੁਝਾਅ:ਉਪ ਤੰਤਰਾਂ ਦੀ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋਣ ਦੀ ਕਿਸਮ ਨੂੰ ਸੈਟ ਕਰਨ ਲਈ <maxOccurs> (ਜਿਸ ਵਿੱਚ ਬਾਅਦ ਵਿੱਚ ਵਿਸਥਾਰ ਕੀਤਾ ਜਾਵੇਗਾ) ਨੂੰ unbounded (ਅਸੀਮਤ) ਸੈਟ ਕਰੋ。

Sequence ਸੂਚਕਾਂਡ

<sequence> ਉਪ ਤੰਤਰਾਂ ਨੂੰ ਵਿਸ਼ੇਸ਼ ਕਿਸਮ ਦੀ ਕਿਸਮ ਨਾਲ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋਣਾ ਨਿਰਧਾਰਿਤ ਕਰਦਾ ਹੈ:

<xs:element name="person">
  <xs:complexType>
    
      
      
    
  </xs:complexType>
</xs:element>

Occurrence ਸੂਚਕਾਂਡ

Occurrence ਸੂਚਕਾਂਡ ਕੋਈ ਤੰਤਰ ਕਿਸੇ ਤੰਤਰ ਵਿੱਚ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋਣ ਦੀ ਪ੍ਰਕਿਰਿਆ ਨੂੰ ਨਿਰਧਾਰਿਤ ਕਰਦਾ ਹੈ。

ਟਿੱਪਣੀ:ਸਾਰੇ "Order" ਅਤੇ "Group" ਸੂਚਕਾਂਡ (any, all, choice, sequence, group name ਅਤੇ group reference) ਲਈ, ਉਨ੍ਹਾਂ ਦਾ ਮੂਲ ਮੁੱਲ ਮੈਕਸ ਓਕਰਸ ਅਤੇ minOccurs ਹੈ 1。

maxOccurs ਸੂਚਕਾਂਡ

<maxOccurs> ਸੂਚਕਾਂਡ ਕੋਈ ਤੰਤਰ ਕਿਸੇ ਤੰਤਰ ਵਿੱਚ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋਣ ਦੀ ਅਧਿਕਤਮ ਸੰਖਿਆ ਨੂੰ ਨਿਰਧਾਰਿਤ ਕਰਦਾ ਹੈ:

<xs:element name="person">
  <xs:complexType>
    
      <xs:element name="full_name" type="xs:string"/>
      <xs:element name="child_name" type="xs:string" ਮੈਕਸ ਓਕਰਸ = "10"/>
    
  </xs:complexType>
</xs:element>

ਉੱਪਰੋਕਤ ਉਦਾਹਰਣ ਨਾਲ ਪਤਾ ਲੱਗਦਾ ਹੈ ਕਿ ਉਪ ਤੰਤਰ "child_name" "person" ਤੰਤਰ ਵਿੱਚ ਨਾਲੋਂ ਘੱਟ ਇੱਕ ਵਾਰ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋ ਸਕਦਾ ਹੈ (ਜਿਸ ਵਿੱਚ minOccurs ਦਾ ਮੂਲ ਮੁੱਲ ਹੈ 1), ਨਾਲੋਂ ਜ਼ਿਆਦਾ 10 ਵਾਰ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋ ਸਕਦਾ ਹੈ。

minOccurs ਸੂਚਕਾਂਡ

<minOccurs> ਸੂਚਕਾਂਡ ਕੋਈ ਤੰਤਰ ਕਿਸੇ ਤੰਤਰ ਵਿੱਚ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋਣ ਦੀ ਨਿਮਨਤਮ ਸੰਖਿਆ ਨੂੰ ਨਿਰਧਾਰਿਤ ਕਰਦਾ ਹੈ:

<xs:element name="person">
  <xs:complexType>
    
      <xs:element name="full_name" type="xs:string"/>
      <xs:element name="child_name" type="xs:string"
      ਮੈਕਸ ਓਕਰਸ = "10" ਮਿਨ ਓਕਰਸ = "0"/>
    
  </xs:complexType>
</xs:element>

ਉੱਪਰੋਕਤ ਉਦਾਹਰਣ ਨਾਲ ਪਤਾ ਲੱਗਦਾ ਹੈ ਕਿ ਉਪ ਤੰਤਰ "child_name" "person" ਤੰਤਰ ਵਿੱਚ ਨਾਲੋਂ ਘੱਟ 0 ਵਾਰ ਅਤੇ ਨਾਲੋਂ ਜ਼ਿਆਦਾ 10 ਵਾਰ ਪ੍ਰਕਾਸ਼ਿਤ ਹੋ ਸਕਦਾ ਹੈ。

ਸੁਝਾਅ:ਜੇਕਰ ਕੋਈ ਤੰਤਰ ਦੀ ਵਰਤੋਂ ਦੀ ਸੰਖਿਆ ਸੀਮਤ ਨਹੀਂ ਹੋਣੀ ਹੈ ਤਾਂ ਮੈਕਸ ਓਕਰਸ ਦੀ ਘੋਸ਼ਣਾ ਮੈਕਸ ਓਕਰਸ = "unbounded" ਇਸਦਾ ਇਸਤੇਮਾਲ ਕਰੋ:

ਇੱਕ ਅਸਲ ਉਦਾਹਰਣ:

ਨਾਮ "Myfamily.xml" ਦਾ XML ਫਾਈਲ:

<?xml version="1.0" encoding="ISO-8859-1"?>
<persons xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="family.xsd">
<person>
<full_name>Tony Smith</full_name>
<child_name>Cecilie</child_name>
</person>
<person>
<full_name>David Smith</full_name>
<child_name>Jogn</child_name>
<child_name>mike</child_name>
<child_name>kyle</child_name>
<child_name>mary</child_name>
</person>
<person>
<full_name>Michael Smith</full_name>
</person>
</persons>

ਉੱਪਰੋਕਤ XML ਫਾਈਲ ਵਿੱਚ "persons" ਨਾਮ ਦਾ ਮੂਲ ਤੱਤ ਹੈ।ਇਸ ਮੂਲ ਤੱਤ ਦੇ ਅੰਦਰਅੰਦਰ ਅਸੀਂ ਤਿੰਨ "person" ਤੱਤਾਂ ਨੂੰ ਨਿਰਧਾਰਿਤ ਕੀਤਾ ਹੈ।ਹਰੇਕ "person" ਤੱਤ ਨੂੰ "full_name" ਤੱਤ ਹੋਣਾ ਚਾਹੀਦਾ ਹੈ ਅਤੇ ਇਸ ਨੂੰ 5 ਤੱਕ "child_name" ਤੱਤਾਂ ਵਿੱਚ ਹੋ ਸਕਦਾ ਹੈ。

ਇਹ schema ਫਾਈਲ "family.xsd" ਹੈ:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="persons">
  <xs:complexType>
    
      <xs:element name="person" maxOccurs="unbounded">
        <xs:complexType>
          
            <xs:element name="full_name" type="xs:string"/>
            <xs:element name="child_name" type="xs:string"
            minOccurs="0" maxOccurs="5"/>
          
        </xs:complexType>
      </xs:element>
    
  </xs:complexType>
</xs:element>
</xs:schema>

Group ਸੂਚਕਾਂਕ

Group ਸੂਚਕਾਂਕ ਉਪਯੋਗ ਲਈ ਸਬੰਧਤ ਸਬਦ ਤੱਤਾਂ ਨੂੰ ਨਿਰਧਾਰਿਤ ਕਰਨ ਲਈ ਹੈ。

元素组

元素组通过 group 声明进行定义:


  ...

您必须在 group 声明内部定义一个 all、choice 或者 sequence 元素。下面这个例子定义了名为 "persongroup" 的 group,它定义了必须按照精确的顺序出现的一组元素:


  
    
    
    
  

在您把 group 定义完毕以后,就可以在另一个定义中引用它了:

name="persongroup">
  
    
    
    
  



  
    
    
  
</xs:complexType>

属性组

属性组通过 attributeGroup 声明来进行定义:


  ...
</xs:attributeGroup>

下面这个例子定义了名为 "personattrgroup" 的一个属性组:

<xs:attributeGroup name="personattrgroup">
  <xs:attribute name="firstname" type="xs:string"/>
  <xs:attribute name="lastname" type="xs:string"/>
  <xs:attribute name="birthday" type="xs:date"/>
</xs:attributeGroup>

ਤੁਸੀਂ ਜਦੋਂ ਪਰਿਭਾਸ਼ਿਤ ਪ੍ਰਤੀਯੋਗੀ ਸਮੂਹ ਪੂਰਾ ਕਰੋ ਤਾਂ ਇਸ ਤਰ੍ਹਾਂ ਦੂਜੇ ਪ੍ਰਤੀਯੋਗੀ ਸਮੂਹ ਵਿੱਚ ਉਸ ਦਾ ਉਲੇਖ ਕਰ ਸਕਦੇ ਹੋ

<xs:attributeGroup name="personattrgroup">
  <xs:attribute name="firstname" type="xs:string"/>
  <xs:attribute name="lastname" type="xs:string"/>
  <xs:attribute name="birthday" type="xs:date"/>
</xs:attributeGroup>
<xs:element name="person">
  <xs:complexType>
    <xs:attributeGroup ref="personattrgroup"/>
  </xs:complexType>
</xs:element>