XML Schema xml version1 0 xsd schema xmlns
- Slides: 42
XML Schema の例 <? xml version="1. 0"? > <xsd: schema xmlns: xsd="http: //www. w 3. org/2001/XMLSchema" target. Namespace="http: //www. wakhok. ac. jp/~tomoharu/students" xmlns: st="http: //www. wakhok. ac. jp/~tomoharu/students"> <xsd: element name="student"> <xsd: complex. Type> <xsd: sequence> <xsd: element ref="st: family. Name" /> <xsd: element ref="st: given. Name" /> <xsd: element ref="st: email" min. Occurs="0" max. Occurs="2" /> </xsd: sequence> </xsd: complex. Type> </xsd: element> <xsd: element name="family. Name" type="xsd: string" /> <xsd: element name="given. Name" type="xsd: string" /> <xsd: element name="email" type="xsd: string" /> </xsd: schema>
min. Occurs 属性と max. Occurs 属性の指定 <xsd: element ref="st: email" min. Occurs="0" max. Occurs="2" /> n e-mail 要素が0回以上、2回以下出現する。
XML Schema に適合する インスタンス (1) <st: family. Name>安藤</st: family. Name> <st: given. Name>友晴</st: given. Name> <st: email> tomoharu@wakhok. ac. jp </st: email>
XML Schema に適合する インスタンス (2) <st: family. Name>安藤</st: family. Name> <st: given. Name>友晴</st: given. Name> n email 要素がなくてもよい。
XML Schema に適合しない例 <st: family. Name>安藤</st: family. Name> <st: given. Name>友晴</st: given. Name> <st: email> tomoharu@wakhok. ac. jp </st: email> <st: email>aaa@b. com</st: email> <st: email>bbb@hoge. jp</st: email>
sequence
<xsd: sequence> 要素が順番に出現する <xsd: sequence> <xsd: element name="family. Name“ type="xsd: string"/> <xsd: element name="given. Name" type="xsd: string" /> </xsd: sequence> n n family. Name 要素が出てから given. Name 要素が出現 順番の変更や要素の省略は許されない
XML Schema に適合する例 <st: student> <st: family. Name>安藤</st: family. Name> <st: given. Name>友晴</st: given. Name> </st: student>
XML Schema に 適合しない例 (1) <st: student> <st: given. Name>友晴</st: given. Name> <st: family. Name>安藤</st: family. Name> </st: student> n given. Name と family. Name が逆
XML Schema に 適合しない例 (2) <st: student> <st: family. Name>安藤</st: family. Name> </st: student> n given. Name がない
all
XML Schema に適合する例 <st: student> <st: given. Name>友晴</st: given. Name> <st: email> tomoharu@wakhok. ac. jp </st: email> <st: family. Name>安藤</st: family. Name> </st: student>
ダメな XML Schema <xsd: all> <xsd: element ref="st: family. Name" /> <xsd: element ref="st: given. Name" /> <xsd: element ref="st: email“ min. Occurs=“ 0” max. Occurs=“ 3” /> </xsd: all> n max. Occurs = “ 3” という指定はできない。
choice
<xsd: choice> どれか1つの要素が出現する <xsd: choice> <xsd: element ref="it: book" /> <xsd: element ref="it: cd" /> <xsd: element ref="it: dvd" /> </xsd: choice> n 子要素のうち、どれか1つが出現する
XML Schema に適合する例 <it: item> <it: book>蹴りたい背中</it: book> </it: item>
XML Schema の例 <xsd: element name="student"> <xsd: complex. Type> <xsd: sequence> <xsd: element ref="st: family. Name" /> <xsd: element ref="st: given. Name" /> </xsd: sequence> <xsd: attribute name=“number” type="xsd: string" /> </xsd: complex. Type> </xsd: element>
XML Schema に適合する例 <st: student number="abcd“> <st: family. Name> 安藤 </st: family. Name> <st: given. Name>友晴</st: given. Name> </st: student>
XML Schema の例. . . <xsd: element ref="st: user. Name" />. . . <xsd: element name="user. Name"> <xsd: simple. Type> <xsd: restriction base="xsd: string"> <xsd: max. Length value="8" /> </xsd: restriction> </xsd: simple. Type> </xsd: element>
データの制限 <xsd: simple. Type> <xsd: restriction base="xsd: string"> <xsd: max. Length value="8" /> </xsd: restriction> </xsd: simple. Type> n string 型の最大長を8文字に制限する
XML Schema に適合する例 <st: student> <st: family. Name> 安藤 </st: family. Name> <st: given. Name>友晴</st: given. Name> <st: user. Name>tomoharu</st: user. Name> </st: student>
XML Schema の例. . . <xsd: attribute ref="st: student. ID" />. . . <xsd: attribute name="student. ID"> <xsd: simple. Type> <xsd: restriction base="xsd: string"> <xsd: pattern value="d{2}-d{3}" /> </xsd: restriction> </xsd: simple. Type> </xsd: attribute>
正規表現を利用した データの制限 <xsd: simple. Type> <xsd: restriction base="xsd: string"> <xsd: pattern value="d{2}-d{3}" /> </xsd: restriction> </xsd: simple. Type> n pattern 要素の value 属性に正規表現を 指定できる。
XML Schema に適合する例 <st: student. ID="00 -01 -001“> <st: family. Name>安藤</st: family. Name> <st: given. Name>友晴</st: given. Name> <st: email> tomoharu@wakhok. ac. jp </st: email> <st: user. Name>tomoharu</st: user. Name> </st: student>
参考文献・URL n Extensible Markup Language (XML) 1. 0 (Third Edition) n n n http: //www. w 3. org/TR/REC-xml/ XML 1. 0 の仕様書です。 W 3 C XML Schema n n http: //www. w 3. org/XML/Schema XML Schema の仕様書など。
- Slidetodoc
- Slidetodoc
- Version1 0
- Version1 0
- Atribut primeri
- Xsd
- Xsd vs xslt
- Xmlbeans vs jaxb
- Xsd complex type
- There are '39' errors in 'jsp_2_0.xsd'.
- Was ist eine xsd datei
- Xsd best practices
- Photo caption
- Xml l
- Linq language
- Xml schema 예제
- Xml schema root element
- Mapping eer to odb schema
- Wpfapp
- Xml vs xbrl
- Hpe nonstop enscribe to xml
- Flash xml
- Xml dom sax
- Relationship between html sgml and xml
- Haarcascade_frontalface_default.xml download
- Spreadsheet ml
- Xml color picker
- Klavarscript
- Java xml
- Sas xml mapper
- Asynchronous javascript and xml
- Xml
- Dom xml php
- Perbedaan awt dan swing
- Xml file reader
- Xrarse
- Marc xml
- Xml maps are not exportable
- Xml dom
- Netflix api rest
- Microsoft schemas xml
- Vi format xml
- Simple api for xml