Table 3.2 Attributes and Their Syntactical Usage




Download 2,96 Mb.
Pdf ko'rish
bet64/131
Sana14.05.2024
Hajmi2,96 Mb.
#232039
1   ...   60   61   62   63   64   65   66   67   ...   131
Bog'liq
Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

Table 3.2 Attributes and Their Syntactical Usage
 
Attribute Usage
Description
 

A marble element that has a color attribute 
whose value is red. This is an example of a well 
formed attribute expression. The corresponding 
closing tag would be 
.
= "big">
A marble element that has a color attribute 
whose value is red and a size attribute whose 
value is big. You can create as many attributes 
as you like.

A marble element with a color attribute whose 
value is red that has no other content.

Not well formed. The parser throws a fit because 
the attribute values must be contained in quotes.

Not well formed. XML parsers reject valueless 
attributes.
 
Comments
Comments
 
are exactly the same as in HTML: They are a place to write a note to yourself; 
a reminder that is not displayed to the user. Think of comments as virtual Post-It Notes 
for software. Comments are great for reminding yourself about little details that you tend 
to forget while writing.
Here’s what a comment looks like:
like -->


- 59 -
XML parsers ignore everything within comment tags, so you can pretty much use any 
characters in a comment; however, make sure you don’t include the -- string inside the 
comment itself. For example:
like -->
would be considered not well formed, and any XML parser worth its salt would reject it.
Comments can also be arbitrarily long; that is, there is no limit to their size. They can 
span several lines:
absolutely no meaning whatsoever other 
than to take up a lot of space -->
You can also use comments to 
comment out
sections that you don’t want the parser to 
read, for example:
element -->
this element and its contents are being ignored by 
the
parser
 
-->
If you’re in the habit of commenting out code while writing C++ or Java applications, you 
will almost certainly appreciate how useful comments can be for debugging purposes—
especially if you are using a parser that has terse error reporting (for example, “Error in 
document. Please correct and then retry.”). A few words of advice: Please don’t ever use 
a parser that reports errors as tersely as that. 

Download 2,96 Mb.
1   ...   60   61   62   63   64   65   66   67   ...   131




Download 2,96 Mb.
Pdf ko'rish

Bosh sahifa
Aloqalar

    Bosh sahifa



Table 3.2 Attributes and Their Syntactical Usage

Download 2,96 Mb.
Pdf ko'rish