Hướng dẫn XML

TRANG CHỦ XML Giới thiệu XML Cách sử dụng XML Cây XML Cú pháp XML Phần tử XML Thuộc tính XML Không gian tên XML Hiển thị XML HttpRequest XML Trình phân tích cú pháp XML DOM XML XPath XML XSLT XML XQuery XML XML XLink Trình xác thực XML DTD XML Lược đồ XML Máy chủ XML Ví dụ về XML Câu đố XML Chứng chỉ XML

XML AJAX

Giới thiệu AJAX AJAX XMLHttp Yêu cầu AJAX Phản hồi AJAX Tệp XML AJAX AJAX PHP AJAX ASP Cơ sở dữ liệu AJAX Ứng dụng AJAX Ví dụ về AJAX

DOM XML

Giới thiệu DOM Nút DOM Truy cập DOM Thông tin nút DOM Danh sách nút DOM DOM Traversing Điều hướng DOM DOM Nhận giá trị Nút thay đổi DOM DOM Xóa các nút Nút thay thế DOM DOM Tạo nút DOM Thêm nút Nút nhân bản DOM Ví dụ về DOM

Hướng dẫn XPath

Giới thiệu XPath Nút XPath Cú pháp XPath Trục XPath Toán tử XPath Ví dụ về XPath

Hướng dẫn XSLT

Giới thiệu XSLT Ngôn ngữ XSL Chuyển đổi XSLT XSLT <template> XSLT <value-of> XSLT <for-each> XSLT <sắp xếp> XSLT <if> XSLT <chọn> Áp dụng XSLT XSLT trên máy khách XSLT trên Máy chủ XSLT Chỉnh sửa XML Ví dụ về XSLT

Hướng dẫn XQuery

Giới thiệu XQuery Ví dụ về XQuery XQuery FLWOR HTML XQuery Điều khoản XQuery Cú pháp XQuery XQuery Thêm Chọn XQuery Hàm XQuery

DTD XML

Giới thiệu DTD Khối xây dựng DTD Phần tử DTD Các thuộc tính DTD Phần tử DTD so với Attr Thực thể DTD Ví dụ về DTD

Lược đồ XSD

Giới thiệu XSD XSD Cách thực hiện XSD <schema> Phần tử XSD Thuộc tính XSD Hạn chế XSD

XSD Complex

Phần tử XSD XSD trống Chỉ các phần tử XSD Chỉ văn bản XSD XSD hỗn hợp Chỉ báo XSD XSD <nhiều> XSD <anyAttribute> Thay thế XSD Ví dụ về XSD

Dữ liệu XSD

Chuỗi XSD Ngày XSD XSD Numeric XSD Misc Tham chiếu XSD

Dịch vụ web

Dịch vụ XML WSDL XML SOAP XML RDF XML RSS XML

Người giới thiệu

Các loại nút DOM Nút DOM DOM NodeList DOM NamedNodeMap Tài liệu DOM Phần tử DOM Thuộc tính DOM Văn bản DOM DOM CDATA Bình luận DOM DOM XMLHttpRequest Trình phân tích cú pháp DOM Phần tử XSLT Hàm XSLT / XPath

Phần tử complexType của lược đồ XML


❮ Tham chiếu lược đồ XML hoàn chỉnh

Định nghĩa và Cách sử dụng

Phần tử complexType định nghĩa một kiểu phức tạp. Phần tử kiểu phức hợp là phần tử XML có chứa các phần tử và / hoặc thuộc tính khác.

Thông tin phần tử

  • Phần tử chính: phần tử, xác định lại, giản đồ

Cú pháp

<complexType
id=ID
name=NCName
abstract=true|false
mixed=true|false
block=(#all|list of (extension|restriction))
final=(#all|list of (extension|restriction))
any attributes
>

(annotation?,(simpleContent|complexContent|((group|all|
choice|sequence)?,((attribute|attributeGroup)*,anyAttribute?))))

</complexType>

(Dấu? Khai báo rằng phần tử có thể xảy ra 0 hoặc một lần và dấu * tuyên bố rằng phần tử có thể xảy ra 0 hoặc nhiều lần bên trong phần tử complexType)

Attribute Description
id Optional. Specifies a unique ID for the element
name Optional. Specifies a name for the element
abstract Optional. Specifies whether the complex type can be used in an instance document. True indicates that an element cannot use this complex type directly but must use a complex type derived from this complex type. Default is false
mixed Optional. Specifies whether character data is allowed to appear between the child elements of this complexType element. Default is false. If a simpleContent element is a child element, the mixed attribute is not allowed!
block Optional. Prevents a complex type that has a specified type of derivation from being used in place of this complex type. This value can contain #all or a list that is a subset of extension or restriction:
  • extension - prevents complex types derived by extension
  • restriction - prevents complex types derived by restriction
  • #all - prevents all derived complex types
final Optional. Prevents a specified type of derivation of this complex type element. Can contain #all or a list that is a subset of extension or restriction.
  • extension - prevents derivation by extension
  • restriction - prevents derivation by restriction
  • #all - prevents all derivation
any attributes Optional. Specifies any other attributes with non-schema namespace

ví dụ 1

Ví dụ sau có một phần tử tên là "note" thuộc loại phức tạp:

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
  <xs:element name="to" type="xs:string"/>
  <xs:element name="from" type="xs:string"/>
  <xs:element name="heading" type="xs:string"/>
  <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

Ví dụ 2

Ví dụ sau có một kiểu phức tạp, "fullpersoninfo", bắt nguồn từ một kiểu phức tạp khác, "personinfo", bằng cách mở rộng kiểu kế thừa với ba phần tử bổ sung (địa chỉ, thành phố và quốc gia):

<xs:element name="employee" type="fullpersoninfo"/>

<xs:complexType name="personinfo">
  <xs:sequence>
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
  </xs:sequence>
</xs:complexType>

<xs:complexType name="fullpersoninfo">
  <xs:complexContent>
    <xs:extension base="personinfo">
      <xs:sequence>
        <xs:element name="address" type="xs:string"/>
        <xs:element name="city" type="xs:string"/>
        <xs:element name="country" type="xs:string"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>

Trong ví dụ trên, phần tử "nhân viên" phải chứa theo thứ tự các phần tử sau: "tên", "họ", "địa chỉ", "thành phố" và "quốc gia".


❮ Tham chiếu lược đồ XML hoàn chỉnh