Q & A IBM 141 (questions 21-40)

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. Is the following XML instance valid ? Yes/No

    XML instance:


    <xml version="1.0"> <!DOCTYPE Root PUBLIC "" "sample.dtd"> <Root> </Root> </xml>

    DTD file:

    <!ELEMENT Root ANY>

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

    No. The file is not well-formed so it cannot be valid. The file is not well-formed because the declaration:

    <xml version="1.0">
    is invalid. The correct form is:
    <?xml version="1.0"?>
  2. What "DTD" stands for ?

    a. Document Type Declaration;

    b. Document Type Definition;

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

    Answer: b.

  3. Is the DOCTYPE declaration compulsory ? Yes/No

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

    No. If the document is not validated against a DTD then the DOCTYPE declaration should be omitted.

  4. Is the following DTD well-formed ? Yes/No
    <!ELEMENT Root ANY> <!ATTLIST Root version CDATA FIXED "1.0" >

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

    No. The well-formed version is:

    <!ELEMENT Root ANY> <!ATTLIST Root version CDATA #FIXED "1.0" >
  5. What does a validating parser if it encounters a valid DOCTYPE declaration but it cannot load the associated DTD file because the given URL is wrong ?

    a. it will continue to parse the document in order to check if it is well-formed;

    b. this is a fatal error: the parsing will stop immediately;

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

    Answer: b.

  6. Can you use URL fragments to specify the location of a DTD, like in the following declaration: (Yes/No)
    <!DOCTYPE Root PUBLIC "" "//www.mihaiu.name/DTDs/sample.dtd#anchor">

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

    No. Even if such an URL is perfectly legal it should not be used with XML parsers.

  7. Is the following DTD declaration valid ? Yes/No

    <!ELEMENT elementName #PCDATA>

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

    No. The corect version is:

    <!ELEMENT elementName (#PCDATA)>
  8. Is the following mixed content model valid ?
    <!ELEMENT elementName2 (#PCDATA, Grade, Year)*>

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

    No. In a mixed content model you cannot control the order of the elements.

  9. Can you retrict the content of an XML element to take only values from an enumeration list (using DTDs) ? Yes/No

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

    No. This is not possible using DTDs.

  10. Is the following attribute list declaration well-formed ?
    <!ATTLIST Test6 an_attribute (value1, value2) #IMPLIED>

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

    No. The correct version is:

    <!ATTLIST Test6 an_attribute (value1 | value2) #IMPLIED>
  11. Can you have external entities in an attribute of type CDATA ? Yes/No

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

    No. Only internally defined entities are allowed.

  12. You have an attribute of enumerated type. What are the valid values for it ?

    a. XML name;

    b. NameChar;

    c. ASCII;

    d. Unicode;

    e. UTF-16;

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

    Answer: b.

    a - too restrictive

    c - too restrictive

    d - not all Unicode characters are allowed;

    e - this is an encoding algorithm that can encode a certain range of characters from the Unicode specification; the set of valid UTF-16 characters is wider than the set of characters allowed in this case.

  13. The values of an attribute of type ID is unique:

    a. per document instance;

    b. per element type from a document instance;

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

    Answer: a

    If the element "ParkLot" has an attribute of type ID and the element "Atom" also has an attribute of type ID then you cannot have an Atom with the same ID as a ParkLot - even if they are not related in any way !

  14. Is the following attribute valid ?
    <!ATTLIST Test4 an_attribute ID #FIXED "value">

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

    No. An attribute of type ID cannot be FIXED.

  15. You have the following XML element:
    <Test5 ID="abc" Ref="abc"> <Year></Year> <Year></Year> </Test5>

    Its associtated DTD is:

    <!ELEMENT Test5 (Grade | Year)+> <!ATTLIST Test5 ID ID #IMPLIED Ref IDREFS #REQUIRED >

    Is it legal to define a reference to itself ? Yes/No

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

    Answer: Yes.

  16. Is the following DTD valid ?
    <!ELEMENT Year EMPTY> <!ATTLIST Year Img1 ENTITY #IMPLIED Img2 ENTITY #IMPLIED marc NOTATION (Not500 | Not501) #IMPLIED> <!NOTATION Not500 PUBLIC "a" "b"> <!NOTATION Not501 PUBLIC "c" "d">

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

    No. An empty element cannot have a notation attribute.

  17. Is the following DTD valid ?
    <!ELEMENT Test5 (Grade | Year)+> <!ELEMENT Grade EMPTY> <!ELEMENT Year EMPTY> <!ATTLIST Test5 Year NMTOKEN #IMPLIED marc NOTATION (Not500 | Not501) #IMPLIED marc2 NOTATION (Not500 | Not501) #IMPLIED >

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

    No. An element cannot have more than 1 notation associated to it.

  18. Is the following attribute-list valid ? Yes/No
    <!ATTLIST Test1 someId1 ID #IMPLIED someId2 ID #IMPLIED>

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

    No. No element can have 2 attributes of type ID.

  19. Can you use the keywords IGNORE and INCLUDE in the internal subset of a DTD ? Yes/No

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

    No. They can only be used in the external subset.

  20. Can you nest DTD conditional sections ? Yes/No

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

    Answer: yes.

    <!ENTITY % TestCondition "INCLUDE"> <![%TestCondition; [ <!ELEMENT Test9 EMPTY> <![IGNORE [ <!ELEMENT Test11 EMPTY> ]]> ]]>

    The element Test11 will be ignored by the parser.


I wish you success in your certification effort.



Best regards,
Razvan MIHAIU




Razvan Mihaiu � 2000 - 2024