XML Master Professional Database Administrator: Sample Questions

Here are some sample questions.

Section 1   Overview

Question 1.

Select two of the following that are functions required for all XQuery processors conforming to XQuery 1.0.

A. Processes XML data that is valid against a DTD and that conforms to “Namespaces in XML” or “Namespaces in XML 1.1”
B. Imports the element declarations, attribute declarations, and type definitions from an XML Schema
C. Supports all functions defined under the “XQuery 1.0 and XPath 2.0 Functions and Operators” specification
D. Serializes query results (serializes as an octet data string)

Click here for the correct answer

>> Return to Sample Questions Index

Section 2   XQuery, XPath

Question 2.

You wish to execute an XQuery on the following [example.xml] to obtain [Output Result]. Select the correct XQuery to obtain [Output Result]. Assume that the code attribute value of the log element noted in [example.xml] matches the code attribute value of the list element. Select any 1 option.

[example.xml]
<logList>
  <list code="w001" message="Warning1"/>
  <list code="w002" message="Warning2"/>
  <list code="e001" message="Error1"/>
  <list code="e002" message="Error2"/>
  <day date="2007-12-01">
    <log time="10:00:00" code="w001"/>
    <log time="14:00:00" code="e001"/>
  </day>
  <day date="2007-12-02">
    <log time="13:00:00" code="e002"/>
    <log time="15:00:00" code="e001"/>
  </day>
</logList>

[Output Result]
<result>
  <log date="2007-12-01" time="10:00:00" message="Warning1"/>
  <log date="2007-12-01" time="14:00:00" message="Error1"/>
  <log date="2007-12-02" time="13:00:00" message="Error2"/>
  <log date="2007-12-02" time="15:00:00" message="Error1"/>
</result>

A.
<result>{
  let $doc := fn:doc("example.xml")
  for $log in $doc//log
  return
    <log>{
      $log/../@date,
      $log/@time,
      $doc//list[@code eq $log/@code]/@message
    }</log>
}</result>

B.
<result>{
  let $doc := fn:doc("example.xml")
  for $log in $doc//log
  return
    <log>{
      ../@date,
      @time,
      ../../list[@code = $log/@code]/@message
    }</log>
}</result>

C.
<result>{
  let $doc := fn:doc("example.xml")
  for $day in $doc//day
  return
    <log>{
      $day/@date,
      $day/log/@time,
      $doc//list[@code eq $day/log/@code]/@message
    }</log>
}</result>

D.
<result>{
  let $doc := fn:doc("example.xml")
  for $day in $doc//day
  return
    <log>{
    @date,
      log/@time,
      ../list[@code = $day/log/@code]/@message
    }</log>
}</result>

Click here for the correct answer

>> Return to Sample Questions Index

Section 3   Manipulating XML Data

Question 3.


A certain XMLDB can store an XML document as a model based on XML Information Set (Infoset), and retrieve the stored XML data via XQuery. Select two of the following statements that incorrectly explain the results of storing [example.xml] in an XMLDB, and then retrieving the XML data from the XMLDB. This question takes into account ignorable white space such as line feeds or indents in the XML document.

[example.xml]
<content lang="English"
     category="literature
        classic">silence<space> </space>...
silence</content>

A.
When the content element is retrieved via XQuery, the category attribute is always first in order before the lang attribute.

B.
When the content element is retrieved via XQuery, a line feed within the category attribute value is converted to a space (#x20) character.

C.
The execution result of XQuery “fn:string(fn:doc('example.xml')/content)” is the following:
(assume that the XML data in the XMLDB can be referenced with “fn:doc('example.xml')”)
silence ...
silence

D.
The execution result of XQuery “fn:doc('example.xml')/content//text()” is the following:
(assume that the XML data in the XMLDB can be referenced with “fn:doc('example.xml')”)
silence ...silence

Click here for the correct answer

>> Return to Sample Questions Index

Section 4   Creating XML Schema and Other XML Database Objects

Question 4.

A certain company manages employee names using XML data ( simplified for this question). The current operating method for employee name information is as shown below.

[[“Current” operating method]]
XML data is as follows:
(the value of the id attribute of the name element is unique within the XML document)

[example.xml]
<data>
    <name id="1">John Smith</name>
    <name id="2">Mary Nelson</name>
</data>

Execute the following [XQuery] when retrieving name information from XML data.
(set the variable $id as the id attribute value in either name element, and then execute the query)

[XQuery]
declare variable $id := "1";
fn:string(fn:doc("example.xml")//name[@id eq $id])

Here, name information is separated into first name and last name; accordingly, the XML data structure is changed. The future operating method is as follows:

[[“Future” operating method]]
Modify the existing [example.xml] into XML data conforming to the DTD shown below. In other words, separate the character string content of the existing name element into two (neither of them is an empty string), using each respectively as the content string for the LastName and FirstName elements. (for example, if the name information is “John Smith,” then “John” becomes the content string for the FirstName element and “Smith” becomes the content string for the LastName element) However, there is no document type definition in the new XML data.

[DTD defining the new structure] (root element (document element) is the data element)
<!ELEMENT data (name)*>
<!ELEMENT name (FirstName, LastName)>
<!ATTLIST name id NMTOKEN #REQUIRED>
<!ELEMENT LastName (#PCDATA)>
<!ELEMENT FirstName (#PCDATA)>

When [XQuery] is not modified at this time, which one of the following is a correct explanation of the [XQuery] execution result for the same name element (e.g. id attribute value is “1”)?

A.The execution result of “Current” and “Future” is always the same
B.The execution result of “Current” and “Future” is always different
C.By comparison, “Future” and “Current” appear to lead to different results; however, the results could be the same under some circumstances

Click here for the correct answer

>> Return to Sample Questions Index

Go To HOME