笔记20051101
一个例子:
2 <xsd:schema
3 xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
4 elementFormDefault="qualified"
5 >
6 <xsd:element name="Recipe">
7 <xsd:annotation>
8 <xsd:documentation>
9 A Recipe from the 1782 English HouseKeeper book
10 </xsd:documentation>
11 </xsd:annotation>
12
13 <xsd:complexType>
14 <xsd:sequence>
15 <xsd:element ref="title" />
16 <xsd:element ref="Body" />
17 </xsd:sequence>
18 </xsd:complexType>
19 </xsd:element>
20
21 <xsd:element name="title" type="xsd:string">
22 <xsd:annotation>
23 <xsd:documentation>The title of a recipe</xsd:documentation>
24 </xsd:annotation>
25 </xsd:element>
26
27 <xsd:element name="Body">
28 <xsd:annotation>
29 <xsd:documentation>contaner for the content</xsd:documentation>
30 </xsd:annotation>
31 <xsd:complexType mixed="ture">
32 <xsd:choice>
33 <xsd:element ref="ingredient" minOccurs="0" maxOccurs="unbounded" />
34 </xsd:choice>
35 </xsd:complexType>
36 </xsd:element>
37
38 <xsd:element name="ingredient" type="xsd:string">
39 <xsd:annotation>
40 <xsd:documentation>A single ingredient</xsd:documentation>
41 </xsd:annotation>
42 </xsd:element>
43 </xsd:schema>
DTD中element元素定义:
2 (
3 annotation?,
4 (complexType|simpleType)?,
5 (unique|key|keyref)*
6 )
7 >
自定义类型示例:电话号码类型(telephoneNumber)
2 <xsd:choice>
3 <xsd:sequence>
4 <xsd:element name="areacode">
5 <xsd:simpleType>
6 <xsd:restriction base="xsd:integer">
7 <xsd:maxInclusive value="999" />
8 </xsd:restriction>
9 </xsd:simpleType>
10 </xsd:element>
11 <xsd:element name="exchange">
12 <xsd:simpleType>
13 <xsd:restriction base="xsd:integer">
14 <xsd:maxInclusive value="999" />
15 </xsd:restriction>
16 </xsd:simpleType>
17 </xsd:element>
18 <xsd:element name="number">
19 <xsd:simpleType>
20 <xsd:restriction>
21 <xsd:maxInclusive value="999" />
22 </xsd:restriction>
23 </xsd:simpleType>
24 </xsd:element>
25 <xsd:element name="extension">
26 <xsd:simpleType>
27 <xsd:restriction>
28 <xsd:maxInclusive value="999" />
29 </sd:restriction>
30 </xsd:simpleType>
31 </xsd:element>
32 </xsd:sequence>
33 <xsd:sequence>
34 <xsd:element name="contrycode" type="xsd:string" />
35 <xsd:element name="number" type="xsd:string" />
36 <xsd:element name="extension" type="xsd:string" />
37 </xsd:sequence>
38 </xsd:choice>
39 </xsd:complexType>
内容原型:
1。字母和数字,例<xsd:pattern value="hello" />,该元素的内容必须是hello。
2。a|b|c,恰好匹配a、b或c之一;a、b、c可以用任何原型替代。
3。(a),与a相同,可以使用括号分组。
4。句号(.),匹配所有除新行符(\n)或回车符(\r)以外的任何单个字符。如b.y匹配boy等。
5。a?,匹配a或什么也不匹配。原型wine?d匹配wind和wined。原型(dis)?comfort匹配comfort 或discomfort。
6。a*,匹配0个或多个a。
7。a+,匹配1个或多个a。
8。a{2,5},匹配2-5个a。也可以是a{2,},匹配两个或以上的a;a{5},匹配5个a。
9。[w-z],匹配单个字符w、x、y或z;[0-9],匹配一个一位数。
10。[^aeiouy0-9],匹配除与[aeiouy0-9]匹配以外的任何串。
11。\r,\n,\t,字符序列分别匹配回车符( )、新行符( )和跳格符()。
当想在XML中创建从一个文档到另一个文档的超文本链接有两种方法:
1。调用XHTML名域并使用HTML链接。例如,
<html xmlns:h="http://www.w3.org/TR/xhtml">
<h:a href="ok.html">this works.</h:a>
</html>
2。XML Linking Language(XLink)。例如,
<p xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:type="simple" xlink:href="ok.xml">this works, too.</a>
</p>
XLink特点:
1。与不止两个端点链接。可以使用XLink创建连接不止两点的链接。
2。多向链接。对HTML,链接有一个锚和一个目标,文档中一般不存在指向当前web页面的任何迹象。你可 以使用XLink创建双向链接。
3。可以使用外部链接集文档。
4。注解链接。
浙公网安备 33010602011771号