XML: Design |
|
Author: Ajith Kallambella
|
|
Problem :
North American Real Estate Associates, a realtor agency would like to convert their inventory listings into XML
format. Until now, they used a commercial application to retrive the information from the database and render it
to their clients in the HTML format.
Apart from being able to supply the inventory information to various different clients (web, handheld, wireless
devices etc.), the new XML-based system should also allow numerous real-estate agents across the country to send
their local inventory listings to a central application. The new listings and/or update of existing listings will
arrive by email as an XML document. A processing application is required to be designed that will analyze the incoming
XML documents once everyday and will bring up to date the master database. |
Question 1 : Which of the following components is LEAST likely to be included in the design? |
|
An XML parser that processes incoming emails
A web agent that allows field agent query information online.
An application to email inventory listings to various agents in XML
format
An XSL stylesheet for rendering information on to wireless devices |
|
Answer : An application to email inventory listings to various agents in XML format.
Read the requirements. Agents send-in the XML documents. When they query for the listings they need the information
to be neatly rendered, not sent back as raw XML documents. All the other options are required components.
|
Question 2 : The company would like to be able to print the listings and give hardcopies to their clients. Implementing
the printing functionality is MOST likely to require: |
|
Changes to the XML parsing process
A change to the XML rendering process and/or XSL stylesheets.
An enhancement to the DTD for inventory listings
Adjustments to the XPath expressions that retrieve specific listings
from the XML documents |
|
Answer : A change to the XML rendering process and/or XSL stylesheets.
Parsing or DTD definition has nothing to do with the rendering process. XPath expressions help you precisely
identify parts of XML document, however they don't affect the rendering process either.
|
Question 3 : Which of the following is MOST likely to be implied by this architecture? |
|
Validating the incoming XML document(s) using a DTD and a valiating
parser.
Using static transformations instead of on-the-fly output generation
for rendering the XML documents
Using a SQL modeller to query different parts of the XML document
Using SAX parser API for performance reasons for parsing the incoming
documents |
|
Answer : Validating the incoming XML document(s) using a DTD and a valiating parser.
This is one of the fundamental concepts. A validating parser needs either a Schema or a DTD reference.
Now lets consider other answers given and see why they are wrong, or may not be quite appropriate as the first
one.
"Using static transformations instead of on-the-fly output generation for rendering the XML documents."
Static transformations, though quite helpful for generating quicker response, may not be the best solution
here. Since the agents are expected to be continuously sending in new/updated listings, hardly any information
in our system can be considered static. Since the problem definition does not state the amount of document management
involved, it is better( and wise ) not to assume anything.
"Using a SQL modeller to query different parts of the XML document."
This answer was given just to confuse you Well, SQL modeller can be used to finetune SQL queries for relational
databases. However it has nothing to do with XML!
"Using SAX parser API for performance reasons for parsing the incoming documents."
This answer will most likely be your second guess. The statement is partially true - SAX parser API offers better
performance than DOM parsing. However we don't know anything about the amount of incoming XML documents. Remember
- you cannot and should not assume anything more than what is given in the problem statement. Eventhough a choice
of parser should be made depending on the size of data and the need of flexibility while parsing, the statement
here cannot be generalized. Hence it is not the right answer.
|
Question 4 : Which of the following should NOT be relied upon to locate information of interest when querying the
inventory listing XML documents? |
|
The element type of an element.
An attribute value specified on an element start tag.
A processing instruction contained by the element of interest
Comments on the element declaration for the element of interest. |
|
Answers :
A processing instruction contained by the element of interest.
Comments on the element declaration for the element of interest.
This question has TWO correct answers.
Processing instructions are for XML applications that process the data and do not ( should not!! ) describe
the data contained in the XML itself.
And you know why Comments should not be relied upon - they can lie!
Remember to read the questions with caution. Wherever it does not say Select the best answer, there may be more
than one right answer. You will have to choose all the correct answers in order to get the credit.
|
Question 5 : Which of the following statements is TRUE with respect to the task of validating the incoming XML
document ? |
|
No validation needs to be done since the incoming emails are from
trusted partners
A validating parser is necessary to ensure that incoming documents
are well-formed
Validating parsers should be used for testing only and and should
not be used in production for performance reasons
Using mixed content modelling for DTDs facilitates maximum flexibility
since DTDs can be changed without affecting the validity of existing XML documens |
|
Answer : Using mixed content modelling for DTDs facilitates maximum flexibility since DTDs can be changed without
affecting the validity of existing XML documens.
Since this is a tricky question, lets examine the other options.
"No validation needs to be done since the incoming emails are from trusted partners."
Though true, this approach is too restrictive. What if the trusted partner sends you a malformed XML document?
Can happen in real life right??
"A validating parser is necessary to ensure that incoming documents are well-formed."
You don't need a validating parser to check well-formedness. Validating parser( parsers with Validating feature
turned on ) check for structural compliance of the XML document with respect to the Schema/DTD. Any parser( even
non-validating ) should be able to check for well-formedness and that is a requirement!! Remember a malformed XML
document is not an XML document. A well-formed XML document is not necessarily valid. A valid document implies
well-formedness.
"Validating parsers should be used for testing only and and should not be used in production for performance
reasons."
No! No! No! If you need validation, you should come to terms with performance issues. Often the cost of not validating
and dealing with incongruous information surpasses the benefits of performance gains. More over, what is the use
of testing with validation and turning off in production?? My boss would fire me if I did that
"Using mixed content modelling for DTDs facilitates maximum flexibility since DTDs can be changed without
affecting the validity of existing XML documens."
A mixed content model allows you to define an either-or pattern for elements. For instance, if the original DTD
has the definition -
<ELEMENT PropertyType ( Residential | Commercial )>
assuming Residential and Commercial are other elements defined in the DTD, you can safely add another type to
the mixed content model say, VacantLot.
<ELEMENT PropertyType ( Residential | Commercial | VacantLot )>
By doing so, you will not be affecting the validity of existing XML documents. I hope you understand why
|
Question 6 : Which of the following is the BEST approach for storing the listing information ? |
|
Separate XML documents should be used one for each inventory listing
All inventory listings should be combined into a large single XML
document
Storing the information in a relational database and being able to
generate XML documents on the fly allows maximum flexibility
How to store the information really depends on the parser used by
the application |
|
Answer : Storing the information in a relational database and being able to generate XML documents on the fly
allows maximum flexibility.
The emphasis here is for flexibility. Though storing XML files/data in relational DB is not something you are
required to do, this approach easily accomadates changes in volume of data that might occur in future.
The other two options -
"Separate XML documents should be used one for each inventory listing."
and
"All inventory listings should be combined into a large single XML document."
sound too restrictive( note the should be clause). They may or may not be the best solution.
Also the option that says
"How to store the information really depends on the parser used by the application"
- is simply ridiculous.
|
|
Your
scores:
|