XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
How you interpret your business rules has a profound impact on XMLdesign

Hi Folks,

Consider this book store document:

<?xml version="1.0"?>
<BookStore storename="BarnesAndNoble">
        <Book>
                <Title>Don't Make Me Think</Title>
                <Author>Steve Krug</Author>
                <Date>2006</Date>
                <ISBN>0-321-34475-8</ISBN>
                <Publisher>New Riders</Publisher>
        </Book>
        ...
</BookStore>

The document is used by a community that has this business rule:

-------------------------------------------------
Business Rule

    The value of Publisher depends on the store:

       If the store is BarnesAndNoble then 
       Publisher can be either Wrox Press or  
       New Riders

       If the store is Borders then Publisher can 
       be either Norton Press or friendsofed
-------------------------------------------------

Given that business rule, this is invalid (because 'friendsofed' is an invalid publisher for the store 'BarnesAndNoble'):

<?xml version="1.0"?>
<BookStore storename="BarnesAndNoble">
        <Book>
                <Title>Don't Make Me Think</Title>
                <Author>Steve Krug</Author>
                <Date>2006</Date>
                <ISBN>0-321-34475-8</ISBN>
                <Publisher>friendsofed</Publisher>
        </Book>
</BookStore>


What is invalid? 

  - Is BookStore invalid? 
  - Or, is Publisher invalid?

Is the business rule a statement about what are valid BookStores? Or, is the business rule a statement about what are valid values of Publisher given its context?

The question is important. It's answer has a profound impact on XML design.


IMPACT ON XML DESIGN

If the business rule is a statement about what are valid BookStores then, when you design your XML Schema, you should position an <assert> element on the BookStore element declaration:

   Assert: Book/Publisher = ('Wrox Press', 'New Riders')

If the business rule is a statement about what are valid values of Publisher given its context then, when you design your XML Schema, you should position <alternative> elements in the Publisher element declaration:

   Alternative: if @storename='BarnesAndNoble' then text() = ('Wrox Press', 'New Riders')
   Alternative: if @storename='Borders' then text() = ('Norton Press', 'friendsofed')

and you should declare the storename attribute to be "inheritable".

You must specify the store name in an attribute value and not in an element name. The following XML design would make it impossible to implement the business rule:

<?xml version="1.0"?>
<BarnesAndNoble>
        <Book>
                <Title>Don't Make Me Think</Title>
                <Author>Steve Krug</Author>
                <Date>2006</Date>
                <ISBN>0-321-34475-8</ISBN>
                <Publisher>New Riders</Publisher>
        </Book>
</BarnesAndNoble>


QUESTION

Is the business rule a statement about what are valid BookStores or is it a statement about what are valid values of Publisher given its context?

/Roger


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS