Chapter 5

1. 

Which is the standard established by INCITS?

  1. XML/SQL

  2. SQL

  3. SQL_XMLGEN

  4. SQL/XML

  5. None of the above

image from book

2. 

Which of these are tools used to generate XML documents and XML document fragments from Oracle Database tables?

  1. Oracle Database PL/SQL built-in procedures

  2. The SYS_XMLGEN function

  3. The DBMS_XMLGEN package

  4. The XSU Java utility

  5. All of the above

image from book

3. 

What does the EXTRACT('/*') method do?

  1. Finds a specific subtree in an XML document stored outside an Oracle database

  2. Pulls a specific subtree from an XMLType XML document, stored within an Oracle database

  3. Retrieves all the content of an XML document from an XMLType stored in an Oracle database

  4. Retrieves all the content of an XML document from an XMLType stored in an Oracle database, in a more readable, properly organized format

  5. None of the above

image from book

4. 

England and Japan are both island nations. They are also in different regions of the world. All countries are contained within regions . How many nodes will this query find?

   SELECT X.XML.EXISTSNODE(    '/demographics/region/country[name="England" and name="Japan"]') FROM XML X WHERE X.ID=2;   
  1. 2

  2. All nodes within both countries

  3. All nodes within both their parent regions

  4. The entire XML document

image from book

5. 

Assume for the following SQL statements that if data can be retrieved for a query that data does exist in the XMLType, as stored in the table called XML. Which statements will retrieve a node and its subtree?

  1.    SELECT X.XML.EXTRACT('/demographics/region/country[name="China"]') FROM XML X WHERE X.ID=2;   
  2.    UPDATE XML SET XML = UPDATEXML(XML, '/demographics/region/country[name="United States"]/state[1]', '<state id="1"><name code=" BC">Arkansas</name><population>0</population></state>') WHERE ID = 2;   
  3.    SELECT X.XML.EXISTSNODE(    '/demographics/region/country[name="China" or name="Bolivia"]') FROM XML X WHERE X.ID=2;   
  4.    SELECT X.XML.GETROOTELEMENT() FROM XML X WHERE X.ID=2;   

image from book

Answers

1.  

Exercise 1 solution

d. SQL/XML is a standard established by INCITS (the International Committee for Information Technology Standards). This standard is established in order to attempt to standardize XML use with SQL in relational databases.

2.  

Exercise 2 solution

e. All of the above. PL/SQL can be used to call functions provided in the DBMS_XMLGEN package. PL/SQL can also be used to generate XML documents using SQL, cursors , and stored procedures, both as output display and as XMLType data (see Appendix B). The SYS_XMLGEN function allows for limited XML data generated, as does the DBMS_XMLGEN package. The easiest method of generating XML documents is to use PL/SQL code because PL/SQL allows for full program control. Full program control allows for the easiest method of converting between relational table structures into XML object hierarchical structures.

3.  

Exercise 3 solution

d. Retrieves all the content of an XML document from an XMLType stored in an Oracle database, in a more readable, properly organized format. Without use of the EXTRACT method, the output will be a single string, with no indenting at the start of each line for each subtree, and no line breaks.

4.  

Exercise 4 solution

a. 0. The query will finding nothing because the and , not the or , operator is used. The two countries cannot be retrieved because they are in two different regions of the world, and each country is a child of one other region node. If the or operator were used instead then both countries would be retrieved, including all subtree data for each country, within each country.

5.  

Exercise 5 solution

a. is correct because the EXTRACT method finds the subtree for the country China. b. is incorrect because being an UPDATE statement, it retrieves nothing, changing content only in a table. c. is incorrect because the EXISTSNODE method returns a 0, meaning nothing is found, or 1, indicating a node was found. The EXISTSNODE method does not actually return a node, but only an indication that the node does or does not exist. d. is also incorrect because the GETROOTELEMENT method returns the root element only, excluding its subtree, which happens to be the rest of the XML document.



Beginning XML Databases
Beginning XML Databases (Wrox Beginning Guides)
ISBN: 0471791202
EAN: 2147483647
Year: 2006
Pages: 183
Authors: Gavin Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net