I understand this question has been previously discussed in this forum, but past threads were inconclusive as to whether the right answer is c or d. Can any one explain kindly, as to what is right answer to this question.
42. An XML-based employee records application is populated from a back-end relational database. Each employee has a unique numeric employee ID number that serves as the database key for that employee. The XML has an associated DTD. Validating the employee ID data would be: Single Select - Please select the best answer (one and only one choice must be selected). a) Handled by the parser associating the employee name to a unique ID attribute with the XML employee application providing the business logic or functionality.b) Handled by the parser associating a unique ID element with the XML employee application providing the business logic or functionality. c) Handled by the XML parser using a SAX parser and relying on event-handling to capture the value of a unique ID attribute and the XML employee application would deal with user interface and rendering issues. d) Handled by the XML parser as a non-unique CDATA attribute, with verification, business logic and functionality being provided by the XML employee application. e) Stored in an empID element, with a SAX parser capturing the element's character content and evaluating it, reporting the result to the XML employee application for further processing.
"a" would be my choice. Why not "b" --> a unique ID element Why not "c" --> I favour DOM to SAX for this job Why not "d" --> non-unique CDATA attribute Why not "e" --> same reason as for "c" This is just my hunch. No strong reasoning available :-)
The key words are a unique numeric employee ID number! a) and c) must be wrong, since ID attribute cannot have numeric value. b) is wrong since no ID element allowed. d) is irrelevant. Only e) is correct, since SAX can handle this situation by storing empID in a HashSet or something similar in other languages, and validate every new empID encountered against the existing ones. Event handling is the advantage of SAX! [ October 21, 2002: Message edited by: Roseanne Zhang ]
e) Stored in an empID element, with a SAX parser capturing the element's character content and evaluating it, reporting the result to the XML employee application for further processing. Not sure how you figure e to be correct. You are in no way using the DTD to even attempt to check for uniqueness here - wether its a numeric value or not. Also - who says that the ID attribute cant be numeric? It maybe a string literal representing that number - which means they cant be 'typed' numerically - butr its not a big hassle for an application to convert it to that type. Shoot me down here - I really am just thinking out land and hoping for some straightening up - but this is just how it seems to me right now.
Also - who says that the ID attribute cant be numeric?
ID type must contain a XML name and a name must not start with a number. So, if you want to use a number, you need to convert it to a XML name, eg. preced it with underscore character. Adrian
Joined: Mar 18, 2002
ID type must contain a XML name Of course it does - I even wrote that down in my handwritten notes! Is there a known correct and undisputable answer? Where did this question originate?
Joined: Nov 14, 2000
IBM's answer is d). I accept that as correct answer. Why? a) b) c) are excluded as I stated above. CDATA non-unique attribute and non-unique sub-element empID actually serve the same purposes. We need to use business logic to keep the actually unique numeric empIDs. Then, why d), but not e)??? The problem is SAX, Jayadev's hunch was correct. The key words for this is "An XML-based employee records application is populated from a back-end relational database." We want to keep the records, and SAX cannot do that! If we keep the records in a data structure, DOM tree should be the natural conclusion. Now, conclusive, d) is the only correct answer! Hats off to those people for verifying the answer in http://viktor99.virtualave.net/IBM141a.html. Their explanation on this question was unclear. However, their hard work to make the sample test answers 100% correct paid-off!!! Huge thanks!!! I'll send this link to them, it might help future test preparers. Roseanne P.S. Thumb-up to IBM, this is a real hard and high quality question. [ November 10, 2002: Message edited by: Roseanne Zhang ]
Thank you, Roseanne, for your e-mail to me. This was just by chance I checked my hotmail today I have already updated the reference page. The problem in question 42 explanation in IBM Sample Test 141 Reference was just because of outdated broken link to Javaranch forum discussion topic. The URL of the forum has been changed since March 5th, 2002. In fact, I did not touch that stuff since that time, and now I do not even know whether the IBM 141 mock test is exactly the same as it was before March 5th, 2002 or not. (I am going to keep the "last updated" date before I check it) Question 42 was also discussed at that time, please see the corrected links from answers. As I recall now, I was not satisfied with either of the explanations provided. I have the same feeling now I must say ... . Best Regards, Viktor