Re: [xml-dev] RE: [Summary #2] Should Subject Matter Experts Determine XML Data Implementations?
Roger,
I'd also agree that this is a case of inadequately determining requirements, but I'd also argue that this is one of those situations where a difference in design in the first place may have been more appropriate. Consider the original example:
<Payment>
<Method>Paypal</Method>
<Method>money order</Method>
<Method>cashier's check</Method>
</Payment>
In this particular case, the use of an alternate envelope doesn't make a lot of sense here - it makes it more difficult to write queries against it, it makes it more difficult to build interfaces around it, and so forth. To me, this is one of those cases where you'd be better of going with an attribute, especially once the model has been produced:
<Payment>
<Method monetized="true">Paypal</Method>
<Method monetized="false">money order</Method>
<Method monetized="false">cashier's check</Method>
</Payment>
and of course, you can set a default on the attribute in at least XSD, if this is getting verbose:
<Payment>
<Method monetized="true">Paypal</Method>
<Method>money order</Method>
<Method>cashier's check</Method>
</Payment>
The advantage here is that your enumerations remain simple, as an XQuery that populates a list option might illustrate
let $payment := $myObj//Payment[1]
let $selectBox := <select>
{for $method in $payment return
<option value="{string($method)}"
selected="{if ($method/@monetized='true') then 'selected' else ''}">{string($method)}</option>
}
</select>
The point I'm trying to make here though is that in general, when designing a schema that's already in active use, design such that structure remains backward compatible and that properties changes that manifest are either additions to the existing scheme (with an informal agreement to deprecate the use of a given element that is no longer in use) or are attributes that determine the characteristics of the object so being modeled.
Schemas evolved, and sometimes you do have to go in and redesign from the ground up ... but this should definitely be a major version type of change with the understanding that less significant changes should augment rather than rearrange structure until such time as the schema requires major rework.
-- Kurt
On Tue, Oct 14, 2008 at 4:45 PM, Costello, Roger L.
<costello@mitre.org> wrote:
Hi Folks,
Below is an example of a business interest influencing an XML data
design.
QUESTIONS:
1. Do you agree with my example? Would you revise it in any way?
2. Can you think of another simple, compelling example of a business
interest influencing an XML data design?
EXAMPLE OF BUSINESS INTERESTS INFLUENCING XML DATA DESIGN
A SME specifies, "There are three methods of payment: Paypal, money
order, or cashier's check."
Here is an XML data design which expresses the SME's specification:
<Payment>
<Method>Paypal</Method>
<Method>money order</Method>
<Method>cashier's check</Method>
</Payment>
Then, a business person announces, "Our business has a partnership with
Paypal. We earn money each time a customer pays using Paypal. While we
do accept the other payment methods, we earn no money with them. So, be
sure to design the data so that Paypal is accentuated and the others
are de-emphasized."
To de-emphasize the two other payment methods, the above XML data
design is modified so that they are put lower in the data hierarchy:
<Payment>
<Method>Paypal</Method>
<Alternate>
<Method>money order</Method>
<Method>cashier's check</Method>
</Alternate>
</Payment>
Thus we see an example of the influence of business interests on XML
data design.
--
Kurt Cagle
Managing Editor,
xml.comO'Reilly
kurt@oreilly.com