• Internal Parameter Entity Declaration
  • Microsoft Word Applied xml a toolkit for Programmers Wiley doc




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

    !ELEMENT
    to (
    #PCDATA
    )>


    - 90 -
    <
    !ELEMENT 
    from (
    #PCDATA
    )>
    <
    !ELEMENT 
    content (
    #PCDATA
    )>
    <
    !ATTLIST 
    letter priority 
    ENTITY #REQUIRED
    >
    ]>


    &Alex
    &Faraz
    Hi Alex. Good luck on the exam!


    &Alex
    &Faraz
    How did the exam go?


    During parsing, the parser follows all the entity references and pieces the document 
    together in memory so that (in memory) it now looks like this:


    Alex Ceponkus, Canada
    Faraz Hoodbhoy, USA
    Hi Alex. Good luck on the exam!


    Alex Ceponkus, Canada
    Faraz Hoodbhoy, USA
    How did the exam go?


    The key point in this example is that we used entities that were declared and defined 
    inside the DTD, in the main XML document.
    Internal Parameter Entity Declaration
    Parameter Internal Entity declarations are essentially useful for making your DTD more 
    human readable and accessible. Why should this be an important consideration? It 
    makes going back and changing your DTD easier (after all, who remembers what they’ve 
    written months ago?). The argument could be made that you could just as easily 
    accomplish this with extensive commenting. Nevertheless, it is a more comprehensive 
    option than commenting. And like most structural things, it’s harder to do the first time, 
    but makes life much easier in the long run.
    Let’s say, for example, that you have a DTD of an XML document with a root element of 
    cars. Each car element has a product_code attribute of string type that you later decide, 
    should be of type NMTOKENS (to ensure that each product_code is devoid of white 
    space—makes comparisons easier for the XML application.) Furthermore, let’s say that 
    you’ve got several attributes (say delivery_code and distributor_code), all of which are 


    - 91 -
    supposed to have the same format (say string or NMTOKEN). Instead of changing each 
    attribute from CDATA to NMTOKEN, you could assign an internal parameter entity called 
    code_format that is referenced each time for each attribute’s type. Similarly, let’s say you 
    do the same for each attribute’s default value. By changing the internal parameter entity 
    statements, you instantly change the attribute type and default value for all concerned 
    attributes.
    For example:
    <

    Download 2,96 Mb.
    1   ...   82   83   84   85   86   87   88   89   ...   131




    Download 2,96 Mb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Microsoft Word Applied xml a toolkit for Programmers Wiley doc

    Download 2,96 Mb.
    Pdf ko'rish