1. | XML data files must follow some simple rules in order to be called “well formed” and to be used by standard XML parsers. Which one of these choices is not one of the rules?
|
|
2. | Several technologies have been developed for validating the contents of XML files against a defined set of element and attribute names and other formatting specifics. Which of these is the most up-to-date technology?
|
|
3. | You are creating an application that loads data from XML data files into a DataSet. The XML data file contains several items that you do not want to load for this particular application. How can you most easily accomplish this?
|
|
4. | You would like to output a copy of the current DataSet schema to a disk file, to use for performing validation in another part of your application. How can you quickly accomplish this?
|
|
5. | You would like to create XML output from your DataSet. When you call the WriteXml method, the resulting XML output looks like this: <jobs> <id><1/id> <job_desc>New Hire - Job not specified</job_desc> <min_lvl>10</min_lvl> <max_lvl>50</max_lvl> </jobs> The application that will be consuming your data requires this format: <jobs description="Chief Executive Officer" min="200" max="225" /> How can you create this output?
|
|
6. | After allowing your user to edit the data in a DataSet, you would like to pass an XML file to a business logic component for verification. The verification logic requires that records changed by the user are easily identifiable, and that any user changes that violate business rules must be reset to the original value. Which feature of the ADO.NET DataSet enables you to capture this information in an XML document?
|
|
7. | Which statement best describes the way that an XmlTextReader works?
|
|
8. | The XML Document Object Model (DOM) has only three base classes at its core. Which of the following is one of the base classes?
|
|
9. | The XML DOM has two similar methods, SelectNodes and SelectSingleNode. What makes these methods similar?
|
|
10. | You are using XML DOM programming in order to create a new structure of XML nodes in your application code. You have created a root node <employeelist> and an <employee> node. As you create the next set of nodes, you would like each new node to be added as the last child of the <employee> node. Which method should you call?
|
|
11. | You’re writing a function that processes XML data. The procedures that call your function pass in a Stream object that contains the XML data. Which method should you call to populate and XmlDocument object?
|
|
12. | What is an advantage of learning to use XPath expressions?
|
|
13. | Your application must do extensive searching through large XML data files. Which option is likely to give you the best performance?
|
|
14. | You are developing an application that processes business transactions from many e-commerce trading partners, in the form of XML documents. At what point, or points, in the data flow is it most important to perform XSD schema validation on the data files that you are exchanging with your business partners?
|
|
15. | You are writing a SQL query to retrieve XML data from Microsoft SQL Server 2000. You would like each column value from the table to be in the form of columnname="value" and you would like the element name to reflect the name of the database table. Which SQL query would you use?
|
|
Answers
1. | C A uniquely named root element, case sensitivity, and matching opening and closing tags are some the rules that define a well-formed XML data file. The third choice is incorrect because validation against a schema is a separate step beyond the rules for well-formed XML. |
2. | B DTD was the original means for validating XML data. XDR was an interim technology, mostly used on the Microsoft platform before the W3C finalized XSD. XSLT is used for creating stylesheets for formatting XML data; it does not perform validation. |
3. | D The first two choices could be used to create the desired result, but either option would result in writing a considerable amount of code. The last option is correct because the IgnoreSchema parameter will not load any data from the source file that doesn’t match the current DataSet schema. Using the InferSchema parameter will cause all the data items to be loaded and will change the schema to include the new data as well. |
4. | C The third option is correct because this produces a disk file with only the schema information. The first option would produce a disk file with both an in-line schema and the data. The second option returns the schema information as a string, so additional programming would be required to save the information to a disk file. The last option is used to input schema information into a DataSet. |
5. | D The ColumnMapping property of each DataColumn determines whether the value for that column is output as an XML element or attribute. The DataSet class does not have a ColumnMapping property. |
6. | A Diffgram is correct. DiffGram output adds a hasChanges attribute to any modified, inserted, or deleted rows. The original values of the data are in a separate <diffgr:before> section of the XML output. UpdateGrams are used to send updates to SQL Server 2000 in the form of XML data files. The DataSet Copy method would retain a record of the original values, but would require more coding to compare the two versions. The DataSet Clone method copies only the structure of the DataSet, not data. |
7. | B The XmlTextReader provides forward-only, read-only access to XML data. The XML DOM XmlDocument provides complete programmatic access to XML data. The XmlDataDocument enables you to treat your data as either a relational table or a hierarchical tree of nodes. There is no class that automatically converts text files to XML. |
8. | C The base classes of the XML DOM are XmlNode, and two collection classes, XmlNodeList and XmlNamedNodeMap. XmlElement, XmlAttribute, and XmlDocument (along with many other classes) are derived from the XmlNode base class. |
9. | D Both methods use XPath expressions to select matching nodes. SelectNodes returns a NodeList collection, and SelectSingleNode returns a reference to the first matching node. These methods can include a tag name in the selection criteria but they can evaluate much more sophisticated patterns that match a node’s position in the document hierarchy or specific data values. |
10. | C The AppendChild method will add the new node as the last child node of the parent (myElement). PrependChild adds the new element as the first child of the parent. The InsertBefore and InsertAfter methods require you to specify a reference node and do not automatically add the new element as a child of the current node. |
11. | B The Load method can read data from a disk file or Stream object. The LoadXml method loads data from a string variable. The ImportNode method reads information from one XmlDocument into another. The ReadNode method reads node information from the current node of an XmlReader object. |
12. | B After you understand XPath expression syntax, you can use it in XML DOM programming, XSLT processing, and other XML-related technologies. XPath expression queries can be optimized for performance if you use XPathDocument and compiled XPathExpression objects, but might not always be the fastest method of locating data. Other methods are available for locating specific nodes, such as the GetElementsbyTagName method and using an XmlReader and testing each node for type and name as it is processed. The last option is incorrect because the XPath specification (like most other XML related technologies) is managed by the W3C and is not proprietary to any single software platform. |
13. | C The XPathDocument (and also some classes in the System.Xml.Xsl namespace), are optimized to perform XPath queries. When you compile an XPath expression, repeated searches with the same expression are further optimized. The XPath document does have a SelectNodes method. The other options are functional but might not provide the best performance. |
14. | C It is most important to validate incoming data files, before you use the information in your own applications or store the information in your database. After you have thoroughly tested your own applications that produce XML output, you should be reasonably sure that the XML output created is in the correct format. Because validation requires extra processing overhead, it is not necessary to validate XML data at every step of processing. The last option is incorrect because validation of XML input files will notify you in advance of trying to process them that the data might be invalid. |
15. | A The first choice is correct because it will create a format of XML output that uses the table name as the element name for each row, and creates an attribute name/value pair for each column name and its data value. The second choice would use the generic <row> element tag name for each data row in the resultset. The third choice creates a custom XML output when a query retrieves data from multiple tables. The last choice is incorrect because it should actually state SELECT * FROM table FOR XML AUTO, ELEMENTS and this would result in a format of XML with no attributes; columns would be written as child elements of the <table> element. |