• Processing Instructions
  • Table 3.3 Built-in XML Entities and Their References




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

    Table 3.3 Built-in XML Entities and Their References
     
    Entity
    Description
    Entity Reference
     
    <
    Less than sign
    <
    >
    Greater than sign
    >
    "
    Quotation mark
    "
    '
    Apostrophe
    '
    &
    Ampersand
    &
     
    In the easiest case, the XML snippet would look like this:

    Faraz < Alex

    Once run through an XML parser, the text output of the above would look like this:
    Faraz < Alex
    This is precisely what we want it to be.


    - 62 -
    In general though, entity references are used for representing bigger entities like files
    documents, or text sections. The parser follows the references and pieces together the 
    entire document. So, let’s say you were writing an essay consisting of an introduction, a 
    body, and a conclusion. If you were to prepare each section separately, declaring each 
    as an entity in your DTD, your XML document would refer to it as follows:

    &introduction;
    &body;
    &conclusion;
     
    The parser would then track down and read the actual introduction, body, and conclusion 
    entities and stuff them into a single document in memory. This enables you to take an 
    object-oriented approach to your XML documents.
    If you’re asking the very important question of how we defined the entities, wait a few 
    more pages: We get into that in the 
    “Making DTDs”
    section.
    So, the generic syntax of using an entity reference is as follows:
    &entity_name; 
    It is an ampersand, followed by the entity’s name (declared in the DTD), followed by a 
    semicolon. No white spaces are allowed.
    Processing Instructions
    Processing instructions (PI)
     
    are a hand-me-down syntax from SGML. The syntax is used 
    to clearly mark up information sections that are specific to your application/application 
    processor (for example, a parser) and nothing else. You could think of it as a coded 
    memo format for your 
    particular processor/application. You use the memo to write specific instructions to your 
    application, instructions that you want to make sure are not thought of as conventional 
    data.
    PIs are particularly useful if your XML document is being processed by more than one 
    parser (say a rich text format [RTF] engine or a CDF display engine). In that case, you 
    may want to include some specific instructions to one engine that you don’t want the 
    other to pay attention to. The way this is done is to express processing instructions in a 
    markup syntax that is different from elements, comments, or attributes. Processing 
    instructions are of the following generic format:
     
    It is a greater-than sign, followed by a question mark, followed by the name of the 
    processor/application the PI is intended for, followed by the instruction and its value. The 
    instruction need not have a value, though it could.
    Let’s take a look at an example. XML uses a PI for one of its most fundamental 
    operations: the XML declaration. In order to tell an XML parser that the document you are 
    passing though it is in XML, you use a PI expressed as follows:

    Remember to keep it case sensitive; using XML in capitals causes the parser to go 
    ballistic.


    - 63 -
    If you were using an RTF engine to insert a page break, here’s the processing instruction 
    you would include in your XML document.


    Download 2,96 Mb.
    1   ...   62   63   64   65   66   67   68   69   ...   131




    Download 2,96 Mb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Table 3.3 Built-in XML Entities and Their References

    Download 2,96 Mb.
    Pdf ko'rish