Q & A IBM 141 (questions 41-60)

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 the following element declarations identical ? Yes/No
    <!ELEMENT Test2 (X* | Y*)> <!ELEMENT Test3 (X | Y)*>


    Answer: No.

    The first element allow any number of X or any number of Y *but* if there is a single X there cannot by any Y and viceversa.

    The second element allows any number of X and Y in *any* combination.

  2. Parameter entities are:

    a. used only in DTDs;

    b. used both in DTDs and document instances;

    c. always parsed entities;

    d. always unparsed entities;


    Answers: a, c

  3. What is the default type for an element in XML Schema ?

    a. QName;

    b. normalizedString;

    c. string;

    d. token;

    e. language;

    f. anyType;


    Answer: f.

  4. If the attribute minOccurs is specified but the attribute maxOccurs is not, what is the default value of the latter ?

    a. minOccurs;

    b. unbounded;

    c. minOccurs + 1;

    d. this is an error; if minOccurs is specified then maxOccurs must be specified also;


    Answer: a.

    In this case maxOccurs attribute will have the same value as minOccurs attribute.

  5. Is it legal to have an element and a complex type with the same name ? Yes/No


    Answer: yes.

  6. Can a simple type (from XML Schema ) have attributes ? Yes/No


    Answer: no.

  7. Can a simple type (from XML Schema ) have children ? Yes/No


    Answer: no.

  8. An attribute specified in XML Schema has a default value. Is this case the attribute can also be:

    a. prohibited;

    b. optional;

    c. required;


    Answer: b.

    A default atribute *must* be optional if it is specified thru XML Schema.

  9. Which of the following can be declared as a direct child of a XML Schema element ?

    a. an element;

    b. an attribute;

    c. none;


    Answer: a,b.

    Both an element and an attribute can be declared as a direct child of a schema element and in this case they can be referenced by another elements using the "ref" attribute.

  10. Is the following XML Schema definition valid ? Yes/No
    <xsd:complexType name="Address"> <xsd:attribute name="paidAmount" type="xsd:double"/> <xsd:sequence> <xsd:element name="Street1"/> <xsd:element name="Street2"/> <xsd:element name="City"/> </xsd:sequence> <xsd:attribute name="test" use="required"/> </xsd:complexType>


    No. All the attributes must be defined after the sequence:

    <xsd:complexType name="Address"> <xsd:sequence> <xsd:element name="Street1"/> <xsd:element name="Street2"/> <xsd:element name="City"/> </xsd:sequence> <xsd:attribute name="paidAmount" type="xsd:double"/> <xsd:attribute name="test" use="required"/> </xsd:complexType>
  11. Is the DTD element type "ANY" equivalent with the XML Schema element "anyType" ? Yes/No


    No. The "ANY" element is more restrictive: it only allows elements that were previously declared in the DTD while the "anyType" element allows even elements that were not previously declared.

  12. Can you nest attribute groups inside other attribute groups ? Yes/No


    Answer: yes.

  13. Is the following element declaration valid in XML Schema ? Yes/No
    <xsd:element name="BlockA" type="xsd:string"> <xsd:complexType> <xsd:sequence> </xsd:sequence> </xsd:complexType> </xsd:element>


    No. It is illegal to specify the type of an element twice:

    a. type="xsd:string";

    b. complexType;

    The element would be valid like this:

    <xsd:element name="BlockA"> <xsd:complexType> <xsd:sequence> </xsd:sequence> </xsd:complexType> </xsd:element>
  14. Which of the following types of nodes can have children ?

    a. attribute nodes;

    b. PI nodes;

    c. document element nodes;

    d. text nodes;

    e. root nodes;


    Answer: c,e

    A root node is a virtual node of the whole document. I said "virtual" because the root node is never actually written in an xml file but its presence is always assumed. The root node is the parent of the document element node.

    PIs, attributes and text never have child nodes.

    Consider the following xml fragment:

    <BlockA> Some Text </BlockA>

    The element BlockA has a child text node that has the value "Some text". Text nodes are nameless and they cannot have child nodes.

  15. Do you have child nodes of type entity references (internal or external) from XPath's perspective ? Yes/No


    No. Always entity references are expanded before XPath expressions are computed.

  16. What is the default axis in XPath ?

    a. child;

    b. parent;

    c. self;

    d. preceding;


    Answer: a.

  17. The child axis (XPath) can select only element nodes. True/False


    Answer: true.

  18. Is the text node a direct child of the enclosing element in XPath ? Yes/No


    No. Even if the parent node of the text element is the enclosing element, the reverse is not true.

  19. What kind of separator can be used in a list datatype in XML Schema ?

    a. comma (",");

    b. whitespace (" ");

    c. dash ("-");

    d. underscore ("_");


    Answer: b.

    Only whitespace can be used as a separator.

  20. Can you define list of lists in XML Schema ? Yes/No


    Answer: no.

I wish you success in your certification effort.

Best regards,

Razvan Mihaiu � 2000 - 2021