Table 3.9 Entity Declaration Types and Their Use




Download 2,96 Mb.
Pdf ko'rish
bet89/131
Sana14.05.2024
Hajmi2,96 Mb.
#232039
1   ...   85   86   87   88   89   90   91   92   ...   131
Bog'liq
Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

Table 3.9 Entity Declaration Types and Their Use
 
Term
Meaning/Description
 
Parameter
Entities that are used solely within the DTD (that is, not in the 
XML document).
General
Entities that are used within the XML document itself.
Internal
Declared internally and used in the same document.
External
Declared in an external file and used in the internal XML 
document (DTD section or markup section).
Internal Parameter 
Entity Declaration
Entities that are internally referenced in the DTD section of 
your XML document. Useful for making your DTD more 
human readable and accessible. Very helpful in creating 
classes of attributes or elements, which make future changes
very easy.
Internal General Entity 
Declaration
Declaring entities that are internally referenced in the markup 
portion of your XML document. Useful for creating entities 
that contain either text or markup (or both), for example, 
acronyms, short forms, or markup sections, which can later 
be referenced into the markup section of your XML 
document.
External Parameter 
Entity Declaration
Declaring entities that have been further described in an 
external DTD. Useful for sharing XML DTD components 
across many XML documents.
External General Entity 
Declaration
Declaring external objects as entities. Useful for maintaining 
an object-oriented approach in your XML documents and 
pulling in non-XML information (for example, images and 
sound clips).
 
Notations Declarations
Finally, the last items to mention about DTDs are Notations Declarations. We briefly 
touched upon them in the attribute list declaration section, but let us now talk about them 
in a little more detail.
Very often you may find the need to process a external information that is not in XML 
format (binary files, image files, sound files, or perhaps database files). In that case, more 
likely than not, your XML parser will not be able to process the information you are 
including. Theoretically, that could kill your application altogether.


- 94 -
Fortunately, there is a way around this using 
notations
. Notation declarations allow to tell 
the parser what to do with information of a particular format or 
notation
, usually by 
assigning an external application to process it for you. The parser tells the application 
what program is usually associated with that particular data so the application knows 
where to find it should it wish to execute it. Here’s an example:
my_format
SYSTEM
"http://my_website.com/my_application.exe">
If the XML document wants to use a file (or data) in my_format
,
it can refer to it in one of 
two ways. First, it can reference it with an external entity. Second, it can include it directly 
in the content of an element by assigning an attribute of type NOTATION (as described it 
the 
Attribute Declaration List section
) and setting the value of that attribute to my_format.
You can also explicitly tell the parser that the contents of an entity are of a non-XML 
format by using the keyword NDATA followed by the declared notation. The advantage of 
doing so is that you explicitly tell the parser not to bother parsing the entity itself, rather 
than letting it read through it and issue an error. Again, an example:
]>

Faraz Hoodbhoy

The important thing to note here is that because the NDATA section explicitly states that 
the resume_file entity contains non-XML data, resume_file entities cannot be referenced 
from within an element’s content as opposed to the usual way by using an entity reference. 
NDATA sections are hence only referenced as the value of the ENTITY or ENTITIES type 
attributes.

Download 2,96 Mb.
1   ...   85   86   87   88   89   90   91   92   ...   131




Download 2,96 Mb.
Pdf ko'rish

Bosh sahifa
Aloqalar

    Bosh sahifa



Table 3.9 Entity Declaration Types and Their Use

Download 2,96 Mb.
Pdf ko'rish