4. Simple Type本章では、Simple Typeについて、説明したいと思います。Simple Typeの定義の構文や、XML Schemaに既に存在するSimple Type型等について、説明します。
XML Schema 4章 Simple Type
4.1 Simple Typeの定義Simple Type とは、子供要素を含まない、内容に文字列しか含まない型を言います。以下の型は、すべて、Simple Typeになります
以下に例を示します。 <shipTo country="US"> <name>Alice Smith</name> <street>123 Maple Street</street> <city>Mill Valley</city> <state>CA</state> <zip>90952</zip> </shipTo> 上は、XML文書の一部になります。name、street、city、state、zipの各要素は、内容モデルにテキストしか含みません。よって、これらの要素はSimple Typeになります。また、 country属性もSimple Typeです。属性値には、もちろん子供要素を含めることができません。よって、すべての属性の型はSimple Typeになります。 Simple Type型の要素を宣言する場合は、type属性の値にSimple Type型の名前を記述します。 <element name="要素の名前" type="Simple Type型の名前" /> 以下に Simple Type型の要素宣言の例を示します。 <xsd:complexType name="USAddress"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="street" type="xsd:string"/> <xsd:element name="city" type="xsd:string"/> <xsd:element name="state" type="xsd:string"/> <xsd:element name="zip" type="xsd:decimal"/> </xsd:sequence> <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/> </xsd:complexType> 上は、例で見たname、street、city、state、zipの各要素の宣言です。type属性には、stringやdecimalが設定されています。これは、XML Schemaに設定されているSimple Typeの名前です。 |
![]()
![]()
|