Group indicators

W3C/XML 2006. 12. 11. 22:53
그룹 지시어 (Group indicators)
그룹(Group)은 엘리먼트의 집합과의 연관을 정의할 때 사용된다.

1. 엘리먼트를 그룹핑(Grouping) 하는 방법
: 그룹핑 안에 엘리먼트를 선언

<xs:group name="studentgroup">
  <xs:sequence>
       <xs:element name="firstname" type="xs:string"/>
       <xs:element name="lastname" type="xs:string"/>
       <xs:element name="birthday" type="xs:date"/>
  </xs:sequence>
</xs:group>
- 선언된 그룹은 다른 그룹이나 complexType 에서 참조될 수 있다.

<xs:element name="student" type="studentinfo">
<xs:complexType name="studentinfo">
  <xs:sequence>
       <xs:group ref="studentgroup">
       <xs:element name="country" type="xs:string"/>
  </xs:sequence>
</xs:complexType>
</xs:element>

@ xml 문서 결과
<student>
  <firstname>Hong</firstname>
  <lastname>Gil-Dong</lastname>
  <birthday>1999.9.9</birthday>
  <country>Korea</country>
</student>


2. 속성을 그룹핑(Grouping) 하는 방법
: 그룹핑 안에 속성을 선언

<xs:attributeGroup name="studentgroup">
  <xs:attribute name="firstname" type="xs:string"/>
  <xs:attribute name="lastname" type="xs:string"/>
  <xs:attribute name="birthday" type="xs:date"/>
</xs:attributeGroup>
- 선언된 Attribute의 그룹은 다른 속성 그룹이나 complexType 에서 참조될 수 있다.

<xs:element name="student" type="studentinfo">
  <xs:complexType>
       <xs:attributeGroup ref="studentgroup"/>
  </xs:complexType>
</xs:element>

WRITTEN BY
손가락귀신
정신 못차리면, 벌 받는다.

,