Danh mục

Professional PHP Programming phần 5

Số trang: 86      Loại file: pdf      Dung lượng: 1.67 MB      Lượt xem: 23      Lượt tải: 0    
Xem trước 9 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

ví dụ thường được sử dụng trong các kịch bản của bạn. Như đã nói, khả năng sử dụng các lớp học của bạn trong nhiều kịch bản khác nhau là một trong những lý do quan trọng để tạo ra chúng.Lập trình hướng đối tượng cho phép lập trình để tham khảo các biến liên quan và các chức năng như một thực thể duy nhất được gọi là một đối tượng hoặc dụ. Kết hợp ba
Nội dung trích xuất từ tài liệu:
Professional PHP Programming phần 5Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com H owever, as we noted above, there is also an alternative syntax, whereby we place the closing slash at the end of the opening element: T he following line defines an empty element i mage , with an attribute s rc w ith the value l ogo.gif : Processing Instructions X ML processing instructions contain information for the application using the XML document. Processing instructions do not constitute the part of the character data of the document – the XML parser should pass these instructions unchanged to the application. The syntax of the processing instruction might be strangely familiar to you: I n the following example, p hp i s the target application and p rint This XML document was created on Jan-07, 1999; i s the instruction: Entity References E ntities are used in the document as a way of avoiding typing long pieces of text many times in a document. Entities are declared in the documents DTD (we will see later how to declare entities, when we look at DTDs in more detail). The declared entities can be referenced throughout the document. When the document is parsed by an XML parser, it replaces the entity reference with the text defined in the entity declaration. There are two types of entities – internal and external. The replacement text for an internal entity is specified in an entity declaration, whereas the replacement text for an external entity resides in a separate file, the location of which is specified in the entity declaration. After the entity has been declared, it can be referenced within the document using the following syntax: &nameofentity; N ote that there should be no space between the ampersand ( & ), the entity name and the semicolon. For example, lets assume that an entity m yname w ith the value Harish Rawat h as been declared in the DTD of the document. The entity m yname c an be referred to in the document as: TEAM FLY PRESENTSSimpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com &myname; T he parser, while parsing the document will replace & myname ; b y H arish Rawat . So the application using the XML document will see the content of the element author as H arish Rawat . Comments C omments can be added in XML documents; the syntax is identical to that for HTML comments: The Document Type Definition T he document type definition of an XML document is defined within a declaration known as the d ocument type declaration . The DTD can be contained within this declaration, or the declaration can point to an external document containing the DTD. The DTD consists of element type declarations, attribute list declarations, entity declarations, and notation declarations. We will cover all of these in this section. B e sure to distinguish between the document type d efinition , or DTD, and the d ocument type d eclaration . T he syntax for a document type definition is: T he r ootelementname i s the name of the root element of the document. The declarations for the various elements, attributes, etc., are placed within the square braces. An XML document can also have an external DTD, which can be referenced with the following syntax: T he r ootelementname i s the name of the root element of the document. The location of the file containing the DTD is h ttp://www.harawat.com/books.dtd . Element Type Declarations T he element type declaration indicates whether the element contains other elements, text, or is empty. It also specifies whether the elements are mandatory or optional, and how many times the elements can appear. An element type declaration, specifying that an element can contain character data, looks as follows: TEAM FLY PRESENTSSimpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com H ere E LEMENT i s a keyword, e lementname i s the name of the element, and # PCDATA i s also a keyword. # PCDATA s tands for parsed character data, that is, the data that can be handled by the XML parser. For example, the following element declaration specifies that the element t itle c ontains character data: T he syntax of an element type declaration for an empty element is: H ere e lementname i s the name of the element, and E MPTY i s a keyword. For example, the following element type declaration specifies that element i mage i s empty: T he syntax of an element type declaration for an element can contain anything – other elements or parsed character data – is as follows: H ere e lementname i s the name of the element and A NY i s a keyword. An element type declaration for an element that contains only other elements looks like this: H ere the element p arentelement c ontains the child elements c hildelement1 , c hildelement2 , etc. For example, the following element type declaration specifies that the element b ook c ontains the elements t itle , a uthors , i sbn , p rice : T he syntax of element type declaration, specifying that p arentelemnt c ontains ...

Tài liệu được xem nhiều:

Tài liệu có liên quan: