XML mock exam

Author: Razvan MIHAIU
razvan_rem@rem_mihaiu.name (please remove '_rem' and 'rem_')
From: www.mihaiu.name
Date: 11/04/2005

Page 1: XML questions 1-20

Page 2: XML questions 21-40

Page 3: XML questions 41-60

  1. Are DTDs well formed XML documents ? Yes/No

    \/\/\/\/\/\/\/\/\/\/

    No. A DTD element does not have an organizational structure of an XML document, specifically it does not have a root element in which other elements are embedded.

  2. DTD comments are in the same format as XML comments ? Yes/No

    \/\/\/\/\/\/\/\/\/\/

    Yes. A valid comment in both DTD and XML look like:

    <!-- COMMENT -->
  3. When the same DTD declaration is found in the internal and external subset, which one has priority ? The one from the external subset or the one from the internal subset ?

    \/\/\/\/\/\/\/\/\/\/

    The one from the internal subset.

  4. How many DOCTYPE declarations can be in a well-formed XML document ?

    • 0
    • 1
    • 2
    • 3
    • unlimited

    \/\/\/\/\/\/\/\/\/\/

    0 or 1. A well-formed XML document can contain a DOCTYPE declaration but this is not mandatory. In any case no valid XML document can contain more than 1 DOCTYPE declaration.

  5. Can you associate a DTD to a section of an XML document ?

    \/\/\/\/\/\/\/\/\/\/

    No. A DTD can only be associated with the root element of the XML document, therefore with the entire XML content.

  6. Is the following DOCTYPE declaration valid ?
    <DOCTYPE RootElement SYSTEM "//www.mihaiu.name/validate.dtd#part2">

    \/\/\/\/\/\/\/\/\/\/

    No. Even if a general purpose URL can contain anchor locations like "#part2" an URL specified in a DOCTYPE cannot contain the hash mark "#" character.

  7. Is the following DOCTYPE declaration valid ?
    <DOCTYPE RootElement PUBLIC "SomeBusiness/DTDs/validate.dtd" "//www.mihaiu.name/validate.dtd">

    \/\/\/\/\/\/\/\/\/\/

    Yes. This particular DTD declaration implicitly contains the SYSTEM identifier, even if the word "SYSTEM" is not contain in the declaration. In fact the declaration should be read as:

    <DOCTYPE RootElement PUBLIC "SomeBusiness/DTDs/validate.dtd" SYSTEM "//www.mihaiu.name/validate.dtd">

    The signification is that the SYSTEM declaration will used if the PUBLIC declaration cannot be resolved. Since there is no standard way of handling URIs like the one mentioned by the PUBLIC declaration, the SYSTEM declaration will probably be used in most cases.

    Observation:

    It is illegal to specify the SYSTEM keyword in the above declaration. If the PUBLIC declaration is used then the SYSTEM declaration will be implied but *not* clearly stated by using the keyword "SYSTEM".

  8. Is the follwing DTD definition valid ?
    <! ELEMENT RPLClient (TestSession)?>

    \/\/\/\/\/\/\/\/\/\/

    No. It is *illegal* to have an empty space between the exclamation mark and the following keyword (in this case ELEMENT).

  9. Is the follwing DTD definition valid ?
    <!ELEMENT RPLClient (TestSession)? >

    \/\/\/\/\/\/\/\/\/\/

    Yes. Empty space and new lines can be used at will in order to improove the readibility of the DTD document. The exception to this rule is that there can be no empty space between the exclammation mark and keyword that follows (the keyword "ELEMENT" in this case).

  10. Is the follwing DTD definition valid ?
    < !ELEMENT RPLClient (TestSession)?>

    \/\/\/\/\/\/\/\/\/\/

    No. All DTD definition must start with "<!". It is illegal to have an empty space or a new line bewteen "<" and "!".

  11. A text element (of type #PCDATA) can contain entity references like & ? Yes / No

    \/\/\/\/\/\/\/\/\/\/

    Answer: yes.

  12. Is the following mixed model ELEMENT valid ? Yes/No
    <!ELEMENT someElement (someChild | #PCDATA)*>

    \/\/\/\/\/\/\/\/\/\/

    No. A mixed model ELEMENT must start with #PCDATA:

    <!ELEMENT someElement (#PCDATA | someChild)*>
  13. Is the following mixed model ELEMENT valid ? Yes/No
    <!ELEMENT someElement (#PCDATA | someChild)>

    \/\/\/\/\/\/\/\/\/\/

    No. A mixed model ELEMENT must end with a cardonality of 0...infinite e.g. it must end with a start "*":

    <!ELEMENT someElement (#PCDATA | someChild)*>
  14. Is the following mixed model ELEMENT valid ? Yes/No
    <!ELEMENT someElement (someData | someChild)*>

    \/\/\/\/\/\/\/\/\/\/

    No. This element is *not* a mixed model element because it only has two children of type names "someData" and "someChild".

  15. Consider the following DTD definition:
    <!ELEMENT someElement (someData | someChild)*>

    Is the following XML valid ? (assume that the nodes someData and someChild are properly defined to match the XML document) Yes / No

    <someElement> <someData> text1 </someData> <someChild Speed="45"/> </someElement>

    \/\/\/\/\/\/\/\/\/\/

    No. The element "someElement" cannot contain the children "someData" and the children "someChild" at the same time. According to the DTD definition the two children are mutually exclusive.

  16. Can you use entities defined in an external file in an attribute of type CDATA ? Yes/No

    \/\/\/\/\/\/\/\/\/\/

    Answer: No.

  17. Can you use entities defined internally (in the DOCTYPE section of the same XML file) in an attribute of type CDATA ? Yes/No

    \/\/\/\/\/\/\/\/\/\/

    Answer: Yes.

  18. Is the following XML valid ?
    <AnElement some_attribute="<UpperCase>">Yes</AnElement>

    \/\/\/\/\/\/\/\/\/\/

    No. It is not legal to include the character "<" in an attribute name. The less-than operator must be represented as "&lt;":

    <AnElement some_attribute="&lt;UpperCase>">Yes</AnElement>

    Observation:

    The greater-then operator does not need to be represented as an entity reference, but it is a good practice to do so:

    <AnElement some_attribute="&lt;UpperCase&gt;">Yes</AnElement>
  19. Is the follwing DTD definition valid ?
    <!ATTLIST TestType some_attrib (Unu, Doi) #IMPLIED>

    \/\/\/\/\/\/\/\/\/\/

    No. A valid definition is:

    <!ATTLIST TestType some_attrib (Unu | Doi) #IMPLIED>
  20. Is the follwing DTD definition valid ?
    <!ATTLIST TestType some_attrib ("Unu" | "Doi") #IMPLIED>

    \/\/\/\/\/\/\/\/\/\/

    No. Commas are forbidden:

    <!ATTLIST TestType some_attrib (Unu | Doi) #IMPLIED>

I wish you success in your certification effort.







Best regards,
Razvan MIHAIU




Razvan Mihaiu � 2000 - 2024