Skip to content

Commit b74bd8b

Browse files
Update schema 約束.md
1 parent dafb1e5 commit b74bd8b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

XML/schema 約束.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 介紹
44
- dtd 語法:
5-
```
5+
```xml
66
<!ELEMENT 元素名稱 約束>
77
```
88
- schema 符合 xml 的語法,xml 語句。
@@ -21,7 +21,7 @@
2121
- 看 xml 中有多少個元素 -> element
2222
- 複雜元素
2323

24-
```
24+
```xml
2525
<element name="person">
2626
<complexType>
2727
<sequence>
@@ -31,7 +31,7 @@
3131
</element>
3232
```
3333
- 簡單元素(寫在複雜元素的中間)
34-
```
34+
```xml
3535
<element name="person">
3636
<complexType>
3737
<sequence>
@@ -43,7 +43,7 @@
4343
```
4444

4545
- 在被約束文件裡面引入約束文件
46-
```
46+
```xml
4747
<person xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4848
xmlns="http://www.example.org/1"
4949
xsi:schemaLocation="http://www.example.org/1 1.xsd">
@@ -59,7 +59,7 @@
5959
- **choice 標籤:** 元素只能出現其中一個。
6060
- **maxOccurs="unbounded":** 表示出現次數沒限制。
6161

62-
```
62+
```xml
6363
<element name="name" type="string" maxOccurs="unbounded"></element>
6464
```
6565
- **any 標籤:** 表示任意元素。
@@ -68,14 +68,14 @@
6868
type: 屬性類型。
6969
use: 屬性是否必須出現。
7070

71-
```
71+
```xml
7272
<attribute name="id1" type="int" use="required"></attribute>
7373
```
7474
- 複雜的 schema 約束
7575
引入多個 schema 文件,可以給每個起一個**別名**
7676
想要引入特定約束文件裡的元素,使用 **別名:元素名稱**。
7777

78-
```
78+
```xml
7979
<company xmlns="http://www.example.org/company"
8080
xmlns:dept="http://www.example.org/department"
8181
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

0 commit comments

Comments
 (0)