In recent years, a large amount of software development activity has migrated from



tải về 2.32 Mb.
Chế độ xem pdf
trang14/16
Chuyển đổi dữ liệu20.09.2022
Kích2.32 Mb.
#184179
1   ...   8   9   10   11   12   13   14   15   16
Core JSP
This text is bold and italic 
This would cause an XML document to be invalid! The proper XML format would be: 
This text is bold and italic 


XML elements, just like HTML elements, can have attributes. In XML attribute 
values must always be quoted: 


In general, it is a good idea to avoid using attributes. Attributes are handy in HTML, 
but in XML attributes can easily be substituted by elements. The following example 
contains exactly the same information as the one above, but with the name stored in a 

element: 
COREJSP 
Problems with attributes include the inability to contain multiple values, as well as the 
fact that attributes are not expandable. 
CDATA and PCDATA 
All XML documents consist of characters, which are generally referred to as character 
data, or CDATA. There are actually two flavors of CDATA, data that should be 
parsed and data that shouldn't be parsed. Within XML data that is to be parsed is 
referred to as PCDATA, and data that should not be parsed is simply referred to as 
CDATA. Escaping characters in XML is complicated, so by defining text as CDATA 
it removes them from the parser and the need for escaping. 
In general it is safe to consider all data in an XML document as PCDATA, except for 
any sequence designated as CDATA within a CDATA declaration. A CDATA 
declaration begins with 
and ends with 
]>.
For example: 
 
I am text that is not parsed; I am surrounded by a CDATA 
declaration 
]> 
 
While this might be uncommon in the majority of XML pages, it is very common in 
automatically generated XML pages where it is not known whether or not included 
data will need to be escaped. This is especially true in JSP pages that are written as 
XML. 


All in all, the XML document format is extremely similar to that of HTML, but has 
much stricter rules for data organization. In fact, many believe that in the future 
HTML will be evolving into a new standard called XHTML, which is the merge of 
the HTML format into XML. In any case, while there are some specific caveats to 
XML formatting, it will in no way seem unfamiliar to the HTML coder. 

tải về 2.32 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   8   9   10   11   12   13   14   15   16




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©tieuluan.info 2022
được sử dụng cho việc quản lý

    Quê hương