[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Separate the data model from presentation and make the data modelelement

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Sun, 22 Nov 2015 17:47:37 +0000

Separate the data model from presentation and make the data modelelement
Hi Folks,

Assertion: Accessing/manipulating element nodes is simpler, easier, and faster than accessing/manipulating text. An element-based data model is better suited to XML's strengths than is a text-based data model.

Proof by example:

Case 1: Retrieve "west"

Text-based data model:

	<edge>garden west door home</edge>

XPath to retrieve "west": 

	substring-before(substring-after(., ' '), ' ')

Element-based data model:

	<edge>
		<garden/>
		<west/>
		<door/>
		<home/>
	</edge>

XPath to retrieve "west": 

	*[2]/name()

Clearly, retrieving "west" in the element-based data model is simpler, easier, and faster.

Case 2: Retrieve a range of data items (2nd to 3rd data items)

Text-based data model:

	<edge>garden west door home</edge>

XPath to retrieve the desired range of data items: 

	tokenize(., ' ')[position() = (2,3)]

Element-based data model:

	<edge>
		<garden/>
		<west/>
		<door/>
		<home/>
	</edge>

XPath to retrieve the desired range of data items: 

	*[position() = (2,3)]/name()

Clearly, retrieving a range of data items in the element-based data model is simpler, easier, and faster.

Of course, at the point of presentation we will want to convert the element-based data model to a text-based data model. 

Recommendation: Separate the data model from presentation details and make data models element-based.

Let's take a dramatic example. Rather than this: 

        <living-room>
            you are in the living room.
            a wizard is snoring loudly on the couch.
        </living-room>

use this as your data model: 

        <living-room>
            <you/><are/><in/><the/><living-room./>
            <a/><wizard/><is/><snoring/><loudly/><on/><the/><couch./>
        </living-room>

and use the former only for presentation.

Do you agree?

/Roger


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


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.