| WWW INFOMATION | |||||||||||||
| XML top >>XML Schema ComplexType ■ComplexType
 コンプレックスタイプは、要素の型定義を行います。シンプルタイプとは違い、要素の内容に子要素を含む場合や、属性を含む場合に使用します。(空要素もコンプレックスタイプで定義します。) 例えば、 
<?xml version="1.0" ?> <Sample ver="1.0"> <aaa>データ</aaa> <!-- 要素bbbは文字列 --> <bbb>123</bbb> <!-- 要素bbbは数値 --> </sample> というようなXMLの定義は 
<?xml version="1.0"  ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/xmlSchema"> <!-- sample要素の型は、TypeForSample型 --> <xsd:element name="sample" type="TypeForSample" /> <!-- データ型TypeForSampleを定義 --> <xsd:complextype> <!-- 子要素定義 --> <xsd:sequence> <xsd:element name="aaa" type="xsd:string"/> <xsd:element name="bbb" type="xsd:integer"/> </xsd:sequence> <!-- 属性ver定義 --> <xsd:attribute name="ver" type="xsd:float" use="required"/> </xsd:schema> というスキーマになります。 子要素定義では、<xsd:sequence>要素を使用していますが、他にも<xsd:choice>、<xsd:all>があります。 
 
 |  | ||||||||||||