Hãy sá»­ dụng tối Ä‘a chức năng Search, trước khi đặt câu há»i
 


Gá»­i Ãá» Tài Má»›i Trả lá»i
  #1 (permalink)  
Old 29-10-2008, 10:19 AM
NgocToan's Avatar
Cá nhân
Enterprise Edition
Thành viên thứ: 127
Tham gia: Aug 2008
Bài viết: 1,498
   
Thông Tin
Tên Thật: Bạch Ngá»c Toàn
Äến từ: Chương Mỹ-Hà Ná»™i
Giới tính:
Công việc: Singer and Coder and Dancer
Sở thích: Khi tôi vui thì tôi hát khi tôi đau thì tôi code!
Cám ơn: 649
ÄÆ°á»£c cám Æ¡n 2,322 lần trong 618 bài viết
Send a message via Yahoo to NgocToan Send a message via Skype™ to NgocToan
Default Giản đơn cho lập trình XML Schema

Phương pháp thứ nhất : Cấu trúc lồng
Viết XLM schema từ trên xuống dưới, nghĩa là viết đến element nào thì định nghĩa element đó. Như vậy, đối với ví dụ trên, chúng ta sẽ bắt đầu với việc đinh nghĩa transcript
- bên trong transcript ta sẽ tiếp tục đinh nghĩa student và unit,
- bên trong student lại định nghĩa studentID,name và degree
- bên trong unit thì định nghĩa code,unitNam và grade
Nói tóm lại, XML scheam sẽ có cấu trúc lồng vào nhau, duới đây là lược đồ của các elements trong XLM schema:

[Chỉ thành viên mới nhìn thấy Link. ]
Code cá»§a schame1.xsd:
 <?xml version="1.0" encoding="utf-8" ?>

<!--

  XML Schema 1

-->

<?xml version="1.0" encoding="UTF-8" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="transcript">

     <xs:complexType>

       <xs:sequence>

          <!-- Start element Student information -->

          <xs:element name="student" maxOccurs="1">

            <xs:complexType>

              <xs:sequence>

                  <xs:element name="name" type="xs:string"  

                       maxOccurs="1" minOccurs="1" />

    <xs:element name="degree" maxOccurs="5" 

minOccurs="1" type="xs:string" />

              </xs:sequence>

              <xs:attribute use="required" name="id">

                 <xs:simpleType>

                   <xs:restriction base="xs:long">

                     <xs:maxInclusive value="999999" />

                     <xs:minInclusive value="100000" />

                   </xs:restriction>

                 </xs:simpleType>

              </xs:attribute>

            </xs:complexType>

          </xs:element>

          <!-- End element Student information -->

          <!-- Start element Unit information -->

          <xs:element name="unit" maxOccurs="unbounded">

            <xs:complexType>

              <xs:sequence>

<xs:element name="unitName" maxOccurs="1" 

minOccurs="1" type="xs:string" />

                 <xs:element name="grade" maxOccurs="1">

                   <xs:simpleType>

                     <xs:restriction base="xs:string">

                        <xs:enumeration value="High Distinction" />

                        <xs:enumeration value="Distinction" />

                        <xs:enumeration value="Credit" />

                        <xs:enumeration value="Pass" />

                        <xs:enumeration value="Fail" />

                        <xs:enumeration value="Incomplete" />

                     </xs:restriction>

                   </xs:simpleType>

                 </xs:element>

              </xs:sequence>

              <xs:attribute name="code" use="required">

                 <xs:simpleType>

                   <xs:restriction base="xs:string">

                     <xs:length value="7" />

                   </xs:restriction>

                 </xs:simpleType>

              </xs:attribute>

            </xs:complexType>

          </xs:element>

          <!-- Start element Unit information -->

       </xs:sequence>

     </xs:complexType>

  </xs:element>

</xs:schema>
 
Nhược điểm của phương pháp lồng:
- Khi viết code theo kiểu lồng vào nhau thì XML schema sẽ có code rất phức tạp. Như các bạn đã thấy, chỉ với một xml đơn giản mà code của XML cũng đã khá rối rắm, nếu xml phức tạp hơn một chút thì sẽ càng khó cho việc debug hơn.
- Việc viết code theo kiểu từ trên xuống không sử dụng lại các element đã định nghĩa.

Phương pháp 2: Cấu trúc riêng lẻ
Äây là cách viết có phần “hướng đổi tượngâ€, chúng ta sẽ định nghÄ©a má»—i element riêng biệt, rồi sá»­ dụng các element này như là kiểu dữ liệu đối vá»›i element khác.Nhu vậy, vá»›i ví dụ trên, chúng ta tiến hành như sau:
- đinh nghĩa transcript
- định nghĩa student
- đinh nghĩa unit
- định nghĩa studentID
- định nghia unitCode
- định nghĩa grade
Trong đó:
- transcrip sử dụng student và unit như là kiểu dữ liệu con
- student sử dụng studentID và grade như kiểu dữ liệu con
- unit sử dụng unitCode như kiểu dữ liệu con
Lược đồ của XML schema :
[Chỉ thành viên mới nhìn thấy Link. ]
Code cá»§a chema2.xsd:
 <?xml version="1.0" encoding="UTF-8" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <!-- annotation: header comments-->

    <xs:annotation>

       <xs:documentation xml:lang="en">

           XML Schema 2

       </xs:documentation>

    </xs:annotation>

    <!-- transcript element with type of transcriptType-->

    <xs:element name="transcript" type="transcriptType" />

    <!-- transcriptType: complextype -->

    <xs:complexType name="transcriptType">

       <xs:sequence>

           <xs:element name="student" type="studentType" 

maxOccurs="1" />

           <xs:element name="unit" type="unitType" 

maxOccurs="unbounded" />

       </xs:sequence>

    </xs:complexType>

    <!-- studentType: complextype -->

    <xs:complexType name="studentType">

       <xs:sequence>

           <xs:element name="name" type="xs:string" 

maxOccurs="1" />

           <xs:element name="degree" type="xs:string" 

minOccurs="1" maxOccurs="5" />

       </xs:sequence>

       <xs:attribute name="id" type="studentID" use="required" />

    </xs:complexType>

    <!-- unitType: complextype -->

    <xs:complexType name="unitType">

       <xs:sequence>

           <xs:element name="unitName" type="xs:string" 

minOccurs="1" maxOccurs="1" />

           <xs:element name="grade" type="gradeType" 

maxOccurs="1" />

       </xs:sequence>

       <xs:attribute name="code" type="codeType" />

    </xs:complexType>

    <!-- StudentID: simpletype -->

    <xs:simpleType name="studentID">

       <xs:restriction base="xs:long">

           <xs:minInclusive value="100000" />

           <xs:maxInclusive value="999999" />

       </xs:restriction>

    </xs:simpleType>

    <!-- codeType: simpletype -->

    <xs:simpleType name="codeType">

       <xs:restriction base="xs:string">

           <xs:length value="7" />

       </xs:restriction>

    </xs:simpleType>

    <!-- gradeType: simpletype -->

    <xs:simpleType name="gradeType">

       <xs:restriction base="xs:string">

           <xs:enumeration value="High Distinction" />

           <xs:enumeration value="Distinction" />

           <xs:enumeration value="Credit" />

           <xs:enumeration value="Pass" />

           <xs:enumeration value="Fail" />

           <xs:enumeration value="Incomplete" />

       </xs:restriction>

    </xs:simpleType>

</xs:schema>
 
 <?xml version="1.0" encoding="UTF-8" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <!-- annotation: header comments-->

    <xs:annotation>

       <xs:documentation xml:lang="en">

           XML Schema 2

       </xs:documentation>

    </xs:annotation>

    <!-- transcript element with type of transcriptType-->

    <xs:element name="transcript" type="transcriptType" />

    <!-- transcriptType: complextype -->

    <xs:complexType name="transcriptType">

       <xs:sequence>

           <xs:element name="student" type="studentType" 

maxOccurs="1" />

           <xs:element name="unit" type="unitType" 

maxOccurs="unbounded" />

       </xs:sequence>

    </xs:complexType>

    <!-- studentType: complextype -->

    <xs:complexType name="studentType">

       <xs:sequence>

           <xs:element name="name" type="xs:string" 

maxOccurs="1" />

           <xs:element name="degree" type="xs:string" 

minOccurs="1" maxOccurs="5" />

       </xs:sequence>

       <xs:attribute name="id" type="studentID" use="required" />

    </xs:complexType>

    <!-- unitType: complextype -->

    <xs:complexType name="unitType">

       <xs:sequence>

           <xs:element name="unitName" type="xs:string" 

minOccurs="1" maxOccurs="1" />

           <xs:element name="grade" type="gradeType" 

maxOccurs="1" />

       </xs:sequence>

       <xs:attribute name="code" type="codeType" />

    </xs:complexType>

    <!-- StudentID: simpletype -->

    <xs:simpleType name="studentID">

       <xs:restriction base="xs:long">

           <xs:minInclusive value="100000" />

           <xs:maxInclusive value="999999" />

       </xs:restriction>

    </xs:simpleType>

    <!-- codeType: simpletype -->

    <xs:simpleType name="codeType">

       <xs:restriction base="xs:string">

           <xs:length value="7" />

       </xs:restriction>

    </xs:simpleType>

    <!-- gradeType: simpletype -->

    <xs:simpleType name="gradeType">

       <xs:restriction base="xs:string">

           <xs:enumeration value="High Distinction" />

           <xs:enumeration value="Distinction" />

           <xs:enumeration value="Credit" />

           <xs:enumeration value="Pass" />

           <xs:enumeration value="Fail" />

           <xs:enumeration value="Incomplete" />

       </xs:restriction>

    </xs:simpleType>

</xs:schema>
 
Vá»›i cách viết code cho từng element riêng lẻ, chúng ta rất dẽ dàng cho việc debug và sá»­ dụng lại các element trong trưá»ng hợp cần thiết, tránh việc dư thừa và code rác.
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=1949]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by NgocToan[/url][/size][/right]
 
Chữ ký
[Chỉ thành viên mới nhìn thấy Link. ]

Technology & Techical Centre VDC-Net2E., JSC.
Address: D7 Lot A/D6 - Nguyen Phong Sac str. (prolonged) - Cau Giay dist. - Hanoi
Mobile: 0904 768 707
Website:[Chỉ thành viên mới nhìn thấy Link. ]
Email :ngoctoan89@gmail.com/ngoctoan@ongame.vn
YM :cherish_snow_ngoctoan
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=1949]Copyright © Diá»…n Äàn BachKhoa-Aptech - NgocToan's Signature[/url][/size][/right]
 
Trả Lá»i Vá»›i Trích Dẫn
Có 2 Thành viên cảm ơn NgocToan vỠbài viết này:
cau2pro9x (31-08-2009), lead_chip (30-10-2009)
Click vào banner dưới đây, để ủng hộ diễn đàn nhé bạn
  #2 (permalink)  
Old 01-11-2008, 05:14 PM
tuylipden's Avatar
Cá nhân
Thực tập sinh
Thành viên thứ: 458
Tham gia: Oct 2008
Bài viết: 18
   
Thông Tin
Tên Thật: tuylipden
Äến từ: ninh bình
Giới tính:
Công việc: www.nhathoangjsc.com
Sở thích: Âm nhạc là một phần tất yếu của cuộc sống
Äiện thoại: 0978.56.52.59
Cám ơn: 16
ÄÆ°á»£c cám Æ¡n 150 lần trong 13 bài viết
Send a message via Yahoo to tuylipden
Default

Mình nghÄ© lần sau trình bày bạn nên xuống dòng chứ để như này rối mắt lắm. Mấy bạn má»›i há»c nhìn thấy rối mắt thì có mà chạy mất dép.^^
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=2078]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by tuylipden[/url][/size][/right]
 
Chữ ký

Welcome to Bachkhoa-Aptech Online Community. We hope tuylipden find much more useful information from our forum. Join us to share our IT interest !!!


[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=2078]Copyright © Diá»…n Äàn BachKhoa-Aptech - tuylipden's Signature[/url][/size][/right]
 
Trả Lá»i Vá»›i Trích Dẫn
  #3 (permalink)  
Old 01-11-2008, 06:34 PM
NgocToan's Avatar
Cá nhân
Enterprise Edition
Thành viên thứ: 127
Tham gia: Aug 2008
Bài viết: 1,498
   
Thông Tin
Tên Thật: Bạch Ngá»c Toàn
Äến từ: Chương Mỹ-Hà Ná»™i
Giới tính:
Công việc: Singer and Coder and Dancer
Sở thích: Khi tôi vui thì tôi hát khi tôi đau thì tôi code!
Cám ơn: 649
ÄÆ°á»£c cám Æ¡n 2,322 lần trong 618 bài viết
Send a message via Yahoo to NgocToan Send a message via Skype™ to NgocToan
Default

à!đó là do skin thôi!do skin lỗi!
bạn thá»­ chá»n lại skin khác để xem xem!
ok ngay ấy mà!thanks
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=2079]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by NgocToan[/url][/size][/right]
 
Chữ ký
[Chỉ thành viên mới nhìn thấy Link. ]

Technology & Techical Centre VDC-Net2E., JSC.
Address: D7 Lot A/D6 - Nguyen Phong Sac str. (prolonged) - Cau Giay dist. - Hanoi
Mobile: 0904 768 707
Website:[Chỉ thành viên mới nhìn thấy Link. ]
Email :ngoctoan89@gmail.com/ngoctoan@ongame.vn
YM :cherish_snow_ngoctoan
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=2079]Copyright © Diá»…n Äàn BachKhoa-Aptech - NgocToan's Signature[/url][/size][/right]
 
Trả Lá»i Vá»›i Trích Dẫn
  #4 (permalink)  
Old 15-08-2009, 09:14 PM
Gbriel's Avatar
Cá nhân
»»----»Vua SPAM ™«----««
Thành viên thứ: 132
Tham gia: Aug 2008
Bài viết: 1,791
   
Thông Tin
Tên Thật: Nguyễn Tất Thành
Äến từ: Hà Ná»™i
Giới tính:
Công việc: Há»c Sinh
Äiện thoại: 0904 832 529
Cám ơn: 478
ÄÆ°á»£c cám Æ¡n 706 lần trong 398 bài viết
Send a message via MSN to Gbriel Send a message via Yahoo to Gbriel Send a message via Skype™ to Gbriel
Default

bác sửa lại mấy cái ảnh đi ạ
bé quá
nhìn đau mắt quá ạ
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=12526]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by Gbriel[/url][/size][/right]
 
Chữ ký
[Chỉ thành viên mới nhìn thấy Link. ] Chuyên cung cấp Hosting và Domain đây [Chỉ thành viên mới nhìn thấy Link. ]
Hosting cực mạnh, giá cực rẻ nhé. Ai có nhu cầu vui lòng liên hệ: 0904.832.529 để biết thêm chi tiết.

[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=12526]Copyright © Diá»…n Äàn BachKhoa-Aptech - Gbriel's Signature[/url][/size][/right]
 
Trả Lá»i Vá»›i Trích Dẫn
  #5 (permalink)  
Old 10-09-2009, 02:24 PM
duybienthuhien's Avatar
Cá nhân
Thực tập sinh
Thành viên thứ: 2219
Tham gia: Apr 2009
Bài viết: 18
   
Thông Tin
Tên Thật: bien
Äến từ: nam dinh
Giới tính:
Äiện thoại: 0972220904
Cám ơn: 1
ÄÆ°á»£c cám Æ¡n 0 lần trong 0 bài viết
Default

Bác nào có thể cho em cái code rõ mà dẽ hiểu hơn được khoong ạ . Mới hoc nên còn khó quá. Mong các bác giúp nha . Email của em là [Chỉ thành viên mới nhìn thấy Link. ].
[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=12908]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by duybienthuhien[/url][/size][/right]
 
Chữ ký

Welcome to Bachkhoa-Aptech Online Community. We hope duybienthuhien find much more useful information from our forum. Join us to share our IT interest !!!


[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=12908]Copyright © Diá»…n Äàn BachKhoa-Aptech - duybienthuhien's Signature[/url][/size][/right]
 
Trả Lá»i Vá»›i Trích Dẫn
  #6 (permalink)  
Old 08-03-2010, 02:34 PM
thangquynho's Avatar
Cá nhân
Thực tập sinh
Thành viên thứ: 10783
Tham gia: Oct 2009
Bài viết: 1
   
Thông Tin
Tên Thật: DAT
Äến từ: nhatrang
Giới tính:
Cám ơn: 0
ÄÆ°á»£c cám Æ¡n 0 lần trong 0 bài viết
Default

bác sửa lại cái ảnh hộ cái.bé quá chẳng thấy gì cả!!!

[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=19891]Copyright © Diá»…n Äàn BachKhoa-Aptech - Posted by thangquynho[/url][/size][/right]
 
Chữ ký

Welcome to Bachkhoa-Aptech Online Community. We hope thangquynho find much more useful information from our forum. Join us to share our IT interest !!!


[right][size=1][url=http://bachkhoaaptech.com/forum/showthread.php?p=19891]Copyright © Diá»…n Äàn BachKhoa-Aptech - thangquynho's Signature[/url][/size][/right]
 
Trả Lá»i Vá»›i Trích Dẫn
Trả lá»i


Ãang Ä‘á»c: 1 (0 thành viên và 1 khách)
 
Ãiá»u Chỉnh
Xếp Bài

Quyá»n Sá»­ Dụng Ở Diá»…n Ãàn
Bạn không thể Gửi bài mới
Bạn không thể Gá»­i trả lá»i
Bạn không thể Gửi File đính kèm
Bạn không thể sửa bài viết của mình

BB code is Mở
Smilies đang Mở
[IMG] đang Mở
HTML đang Tắt
Trackbacks are Mở
Pingbacks are Mở
Refbacks are Mở



Liên Lạc - Trang Chủ - Lưu Trữ - Trở Lên Trên