• (value1|value2|value3)
  • (urgent|normal|low)
  • ENTITY and ENTITIES Attributes
  • Microsoft Word Applied xml a toolkit for Programmers Wiley doc




    Download 2,96 Mb.
    Pdf ko'rish
    bet78/131
    Sana14.05.2024
    Hajmi2,96 Mb.
    #232039
    1   ...   74   75   76   77   78   79   80   81   ...   131
    Bog'liq
    Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

    Enumerated Attributes
    Enumerated attributes are perhaps the most interesting and useful of attribute types. An 
    enumerated attribute is one that can take on values from a specified list of set values. 
    These values are specified in the declaration as well. The general form is as follows:
    (value1|value2|value3)
    default
    >
    This sort of an attribute type is useful in many instances in which you want to use 
    attributes to slot elements, for example, based on priorities. Here’s how to assign a 
    priority attribute with three values (urgent, normal, low) to a mail_item element:
    (urgent|normal|low)
    default
    >
    A valid mail_item element could look like this:

    more mail_item 
    information

    You can specify as many values as you like; however, please keep in mind that XML is 
    case sensitive. In the above example, if Priority = “URGENT”, the parser would declare it 
    invalid because “URGENT” is in the incorrect case. One way of getting around this is to 
    include both cases in your list of acceptable values. A better way is to take care of it in 
    the XML application itself.
    ENTITY and ENTITIES Attributes


    - 80 -
    We’re treating both ENTITY and ENTITIES together because ENTITIES is the plural of 
    ENTITY. The ENTITY and ENTITIES attribute types are a way of inserting entities into 
    attribute values. To use these types, you must have previously declared an entity in your 
    DTD (read the section on entities in this chapter for details on how to do this). The 
    ENTITY/ENTITY keyword is used in the declaration to tell the parser to go find the 
    unparsed entity and pop it into the value of the attribute.
    For example, if you wanted to insert a picture entity in to the value of a priority attribute 
    (say an up arrow), the following steps show you how to do it.
    First, remember that the graphic needs to be declared as an entity somewhere in your 
    DTD. Though we haven’t yet talked about Entity declarations in detail, here’s a possible 
    declaration of it:
    Now that the up_arrow entity has been declared, the attribute declaration could look like 
    this:
    ENTITY
    default
    >
    By declaring this, we’ve now said that a priority attribute can contain any previously 
    declared entity. Thus, a valid mail_item element under the above declaration could look 
    like this:

    more mail item 
    information

    The ENTITIES type essentially tells the parser that a particular attribute can have one or 
    more entities. Continuing our mail_item theme, if you wanted to include two entities in the 
    priority attribute (say an up arrow and a flag), you’d declare the attribute list as follows: 
    ENTITIES
    default
    >
    Assuming that up_arrow and flag are previously declared entities, a valid example of 
    mail_item under this declaration is:


    Download 2,96 Mb.
    1   ...   74   75   76   77   78   79   80   81   ...   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