Q & A IBM 141: "XML and related technologies"

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 DOCTYPE well-formed ?
    <!DOCTYPE Root SYSTEM="../bin/Configuration.dtd">

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

    No. The well-formed form is:

    <!DOCTYPE Root SYSTEM "../bin/Configuration.dtd">
  2. Is it possible to read a subset of data of a large XML document using SAX then navigate the subset using DOM ? Yes/No

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

    Yes, it is possible. This solution should be used if random access is required for the subset document.

  3. The element AnyElement is defined like this:
    <!ELEMENT AnyElement ANY>

    Can this element contain an element <Role> that is not defined inside the associated schema ? Yes/No

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

    No. The AnyElement element can contain only elements that are defined in the associated schema. Pay attention that the element type ("ANY") can mislead you to believe that any element type is possible inside it.

  4. The element AnyElement is defined like this:
    <!ELEMENT AnyElement ANY>

    Can you attach to it any attribute that is a valid XML name ? Yes/No

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

    No. The ANY type refers strictly to the content of the element, not to its attributes. If there is no additional ATTLIST declaration for the AnyElement element then it would have no attributes at all.

  5. Select the strings that are valid XML names:


    1. Role_Type
    2. Role-Type
    3. Role.Type
    4. Role$Type
    5. Role5Type
    6. 5Role5Type
    7. _Role5Type
    8. -Role5Type
    9. :Role5Type
    10. .Role5Type

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

    a, b, c, e, g, i

  6. Can you use the same name for an element, an entity and a notation in the same XML document ? Yes/No

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

    Yes, it is possible but it can lead to confusions.

  7. Which one is better ? a.
    <BillingAdress Street="Calea Bucuresti"> <MailAdress Street="Mihai Eminescu">
    b.
    <Address type="Billing" Street="Calea Bucuresti"> <Address type="Mail" Street="Mihai Eminescu">

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

    The first option (a) is better because we can impose a content model for the elements BillingAddress & MailAddress. In the second case we are not able to impose a content model because a content model cannot be build depending on the value of an attribute.

  8. Is the following element valid ? Yes/No
    <!ELEMENT TestAND5 (#PCDATA | (AAA, BBB) | (BBB, AAA))?>

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

    No. This is a mixed element content. For the mixed content model the order of elements or their number *cannot* be controlled.

  9. Is the following element valid ? Yes/No
    <!ELEMENT TestAND5 (#PCDATA | AAA | BBB)>

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

    No. The number of elements in a mixed content element *cannot* be controlled. As a result the only way to write it is:

    <!ELEMENT TestAND5 (#PCDATA | AAA | BBB)*>
  10. Is the following element valid ? Yes/No
    <!-- Note: The below element implements AAA or BBB (could be one, both (any order) or none) --> <!ELEMENT TestOR1 (AAA | BBB | (AAA, BBB) | (BBB, AAA))?>

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

    No. The above element is not deterministic, that means that if the tag <AAA> is present in the markup you have to look at the next tag in order to know what expression from the DTD matches the tag.

    Exemplification:

    a. the tag from the next xml markup is matched by AAA:

    <TestOR1> <AAA/> </TestOR1>

    b. the tag from the next xml markup is matched by (AAA, BBB):

    <TestOR1> <AAA/> <BBB/> </TestOR1>

    This type of look-ahead is not permitted. As a result this element can be flagged as an error by a validating parser. Pay attention that the parser *may* recover from this error and therefore it may fail to report the error. In any case the above element constitutes an error.

    Obs:

    The same analogy is true for the tag <BBB>.

  11. Is the following element valid ? Yes/No
    <!-- or: AAA or BBB (could be one, both (any order) or none) --> <!ELEMENT TestOR2 ((AAA?, BBB?) | (BBB, AAA))>

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

    Answer: no.

  12. Consider the follwing element definition:
    <!ELEMENT value (#PCDATA)> <!ATTLIST value year CDATA #IMPLIED>

    Which elements are respecting the definition ?

    a.
    <value>35000</value>
    b.
    <value year="2001">40000</value>
    c.
    <value year="2002">38000</value>
    d.
    <value year="two thousand">26000</value>

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

    a,b,c,d. They are all valid! The year attribute is optional.

  13. Consider the follwing element definition:
    <!ELEMENT value (#PCDATA)> <!ATTLIST value year (2000 | 2001) #REQUIRED>

    Which elements are respecting the definition ?

    a.
    <value>35000</value>
    b.
    <value year="2001">40000</value>
    c.
    <value year="2002">38000</value>
    d.
    <value year="two thousand">26000</value>

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

    b. The attribute "year" is mandatory and it can have only 2 valid values "2000" & "2001". Naturally, the string "two thousand" is not the same as "2000".

  14. Consider the follwing element definition:
    <!ELEMENT value (#PCDATA)> <!ATTLIST value year CDATA "1995">

    Which elements are respecting the definition ?

    a.
    <value>35000</value>
    b.
    <value year="2001">40000</value>
    c.
    <value year="2002">38000</value>
    d.
    <value year="two thousand">26000</value>

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

    a,b,c,d. They are all valid!

    The attribute "year" is optional and it has a default value. In the first case (a) a validating parser would supply the default value (1995).

  15. Consider the follwing element definition:
    <!ELEMENT value (#PCDATA)> <!ATTLIST value year CDATA #FIXED "2001">

    Which elements are respecting the definition ?

    a.
    <value>35000</value>
    b.
    <value year="2001">40000</value>
    c.
    <value year="2002">38000</value>
    d.
    <value year="two thousand">26000</value>

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

    Answer: a,b.

    The "#FIXED" keyword states that the attribute must always have the default value, which in this case is "2001".

  16. Is the following attribute definition valid ?
    <!ATTLIST TestXOR year CDATA #IMPLIED "2000">

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

    No. If the attribute is explicitely defined as optional (using the "#IMPLIED" keyword) then a default value *cannot* be provided.

  17. What is the format of DTDs ?

    a. valid xml format;

    b. Extended Backus-Naur Form (EBNF);

    c. general schema format;

    d. ISO 3091 format;

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

    Answer: b.

  18. Are XML and DTD comments in the same format ? Yes/No

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

    Yes. The comment format is as follows:

    <!-- comment -->
  19. DTD declarations from the external subset have priority over the declarations from the internal subset. True/False.

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

    False. The internal subset declarations have higher priority and can be used to override the declarations from the external subset.

  20. What is the "Document Type Declaration" ?


    a. the external DTD subset;

    b. the internal DTD subset;

    c. the associated DTD file;

    d. the DOCTYPE declaration;

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

    Answer: d.

    The DOCTYPE declaration from the beginning of an xml document is the "Document Type Declaration". This declaration is commonly referred as the DOCTYPE declaration.


I wish you success in your certification effort.





Best regards,
Razvan MIHAIU




Razvan Mihaiu � 2000 - 2017