portable data components
TRANSCRIPT
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 1/10
Portable Data Components
[Definition] Portable Data Component: a chunk of markup that can be taken out of one context
and dropped into another context, unchanged. The component does not depend on its context forevaluating its constraints.
First, let's see an example of portable data from T!"#. The example comes from HTML5 for
Web Designers b$ %erem$ &eith.
Portable Blog Post
uppose ( have a blog post titled Sudden Insights. )efore T!"#, ( *ould need to kno* the
context of the blog post in order to decide *hich heading level to use for the title of the post. (fthe post is on the front page, then it appears after an h1 element containing the title of m$ blog:
<h1>Diverse Thoughts</h1>
<h2>Sudden Insights</h2>
<p>Got a new idea? Stop what you are doing and give
attention to it immediately.</p>
)ut if ('m publishing the blog post on its o*n page, then ( *ant the title of the blog post to be alevel one heading:
<h1>Sudden Insights</h1><p>Got a new idea? Stop what you are doing and give attention
to it immediately.</p>
The blog post is not portable data.
The blog post cannot be dropped into ne* contexts *ithout modification.
o*ever, in T!"# ( don't need to *orr$ about *hich heading level to use. ( +ust embed the
blog post in the ne* artile element:
<artile> <h1>Sudden Insights</h1>
<p>Got a new idea? Stop what you are doing and give
attention to it immediately.</p>
</artile>
Now the blog post is portable.
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 2/10
(t doesn't matter *hether it's appearing on its o*n page or on the home page:
<h1>Diverse Thoughts</h1>
<artile>
<h1>Sudden Insights</h1>
<p>Got a new idea? Stop what you are doing and give
attention to it immediately.</p>
</artile>
T!"#'s ne* outline algorithm produces the correct results:
Diverse Thoughtso udden (nsights
This is one example of a portable chunk of markup. -rior to T!"# a chunk of markup
depended on its context. o* *ith the T!"# artile element a chunk of markup can be
made portable.
o* let's see examples of portable data outside the realm of T!"#.
A Portable Data Component -- start/end
There are man$ examples *here the start and end time /date, dateTime0 must be recorded:
Example #1
1ecord the start and end time of a meeting. The meeting starts at 2am and ends at 34am:
<meeting>
<start>!"#!!#!!</start>
<end>1!#!!#!!</end>
</meeting>
Example #2
1ecord the start and end date of a conference. The conference starts on 5ugust 6, 7433 and ends
on 5ugust 8, 7433:
<on$erene>
<start>2!11%!&%!'</start>
<end>2!11%!&%!(</end>
</on$erene>
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 3/10
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 4/10
</-s#simpleType>
</-s#element>
</-s#se0uene>
<-s#assert test
i$ 3e-ists3end44 then
i$ 3start astale as -s#dateTime4 then
-s#dateTime3end4 gt -s#dateTime3start4
else i$ 3start astale as -s#date4 then
-s#date3end4 gt -s#date3start4
else i$ 3start astale as -s#time4 then
-s#time3end4 gt -s#time3start4
else true34
else true34 />
</-s#omple-Type>
A Portable Data Component -- t!me !nter&al 'start/end or start/durat!on(
This is an extension of the start>end portable data component.
5 time interval ma$ be expressed using either of these:
start and end values, or
start and duration values
ere are examples using start>duration.
Example #1
The class starts on !a$ 6, 7433 at Bam and runs for B hours:
Cclass
Cstart74334#46T4B:44:44C>start
Cduration-TBC>duration C>class
Example #2
!$ vacation begins %une 77, 7433 and is for 6 da$s:
Cvacation
Cstart74334877C>start
Cduration-6DC>duration
C>vacation
The constraints on the start>end values are those described earlier.
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 5/10
There is one constraint on the start>duration values: the duration must not be a negative value.
Determining that duration is not a negative value is not straightfor*ard. 9ne *ould think thatthis A-ath expression *ould do the +ob:
xs:duration/duration0 gt xs:duration/E-4;E0
o*ever, that is not correct. (t *ill generate this error:
xs:duration is not an ordered t$pe
(nstead, *hat is reuired is to treat duration as a string and check that the string starts *ith the
letter '-' /i.e., not the letter ''0:
starts*ith/duration, '-'0
ere is the timeinterval portable data component:
Cxs:complexT$pe nameGEtimeintervalE Cxs:seuence
Cxs:element nameGEstartE
Cxs:simpleT$pe Cxs:union memberT$pesGExs:date xs:time
xs:dateTimeE >
C>xs:simpleT$pe
C>xs:element Cxs:choice
Cxs:element nameGEendE min9ccursGE4E
Cxs:simpleT$pe Cxs:union memberT$pesGExs:date xs:time
xs:dateTimeE >
C>xs:simpleT$pe C>xs:element
Cxs:element nameGEdurationE t$peGExs:durationE >
C>xs:choice
C>xs:seuence Cxs:assert testGEif /exists/end00 then
if /start castable as xs:dateTime0 then
xs:dateTime/end0 gt xs:dateTime/start0 else if /start castable as xs:date0 then
xs:date/end0 gt xs:date/start0
else if /start castable as xs:time0 then xs:time/end0 gt xs:time/start0
else true/0
else if /exists/duration00 then
starts*ith/duration, '-'0
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 6/10
else true/0E >
C>xs:complexT$pe
A Portable Data Component -- lengt$
Note: the follo*ing Eportable data componentE message *as posted on the *orld*ide xmldev
list on 5pril 2, 7433. 5 lot of discussion ensued. !an$ people *ere unconvinced that the portablelength component is useful. o, let's first see the component and after*ard is a summar$ of the
xmldev discussion.
Example #1
ere is the altitude of an aircraft, expressed in both feet and meters:
<altitude> <$eet>12!!!</$eet>
<meters>'(,).(</meters>
</altitude>
(t is important that the t*o length values are consistent:
meters $eet 5 12 inhes/$t 5 2.,+ m/in 5 m/1!!m
12!!! 5 12 5 2.,+ 5 !.!1
'(,).(
The follo*ing is invalid because the values are not consistent:
<altitude>
<$eet>12!!!</$eet>
<meters>+!!!</meters>
</altitude>
This example sho*s that there is a constraint bet*een the value of the <$eet> element and the
value of the <meters> element.
Example #2
ere is the distance from m$ home to )oston, expressed in both miles and kilometers:
<distane%to%6oston>
<miles>+!</miles>
<7ilometers>(+.')')(</7ilometers>
</distane%to%6oston>
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 7/10
(t ma$ be desired to express the distance in $ards as *ell:
<distane%to%6oston>
<miles>+!</miles>
<7ilometers>(+.')')(</7ilometers>
<yards>)!+!!</yards>
</distane%to%6oston>
There is a constraint bet*een the value of the Cmiles element, the <7ilometers> element,
and the <yards> element.
Des!red C$ara)ter!st!)s o* a +,engt$+ Data Component
(t *ould be useful to create a data component that:
3. -ermits a length to be expressed in various units7. Hnsures that the values in different units are consistent
6. =an be dropped into different contexts *ithout alteration
@e have created a data component that possesses these characteristics<
Portable ,engt$ Data Component
ere is the portable length data component:
http:>>***.xfront.com>xmlschema33>bestpractice>portabledatacomponents>length.xsd
ere is a sample A!" instance document:
http:>>***.xfront.com>xmlschema33>bestpractice>portabledatacomponents>test.xml
Rebuttal o* t$e Portable ,engt$ Data Component
During discussions on the xmldev list multiple people expressed doubt about the usefulness of
the Eportable length data component.E The$ recommended finding other, more useful Eportable
data components.E
"et's examine their reasons. 1ecall the example that *as provided:
<altitude>
<$eet>12!!!</$eet>
<meters>'(,).(</meters>
</altitude>
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 8/10
otice that the same value is expressed in different units.
Arguments aga!nst t$!s Des!gn
3. tore onl$ one value and convert as needed. That *a$ it can't get out of s$nc. This is inaccordance *ith ormal Form in database theor$ *hich sa$s that information should never be
duplicated.
7. During a *orkflo*, if the values accidentall$ get out of s$nch, ho* *ould one determine
*hich is the correct valueI
6. 5ll measurements have uncertaint$. uppose the altitude measurement has an uncertaint$ of
J> #4 feet. Then the value of Cmeters shouldn't have to be precisel$ 68#K.8
. uppose that the measured distance is 3>6 mile. @hat do $ou put do*n so that the euationscome out exactl$ rightI
#. (t is important to have some indication as to *hich value *as an actual measurement /theremight be more than one0 vs. *hich values *ere computed from the measurement/s0, so one could
distinguish bet*een potential measurement errors and potential computational issues /roundoffs,
etc.0.
Arguments !n a&or o* t$!s Des!gn
3. There are man$ real*orld examples *here the same value is expressed in different units:
(n the L the distance to the next to*n is sho*n in both miles and kilometers
L cars sho* the speed in both milesperhour and kilometersperhour hops in the L& sho* the price of loose fruit and vegetables in both price per imperial
and price per metric *eight
hoes and clothes sold in the L& sho* both L& and HL si?es
!an$ large hotels have multiple clocks, each sho*ing the same time but in differentlocales /e.g., e* ;ork, "ondon, 1ome, ong &ong0
(t is easier for the author of the information to compute and sho* it in different units than it is fort$pical shoppers>consumers to do the calculation.
7. The redundanc$ allo*s for crosschecking. uppose a sign sa$s that the distance to the nextto*n is 34 miles and 644 kilometers:
<distane%to%ne-t%town>
<miles>1!</miles>
<7ilometers>'!!</7ilometers>
</distane%to%ne-t%town>
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 9/10
@e can validate the data to discover that the$ are not consistent. uppose the actual distance is
34 miles. (f there *as +ust one sign, *hich sa$s Distance: 644 kilometers then *e *ould have no*a$ of reali?ing that something is *rong.
"u!del!nes *or .$en to Express t$e %ame alue !n ult!ple D!**erent 0n!ts
Hxpress a value in multiple different units *hen the cost of deriving>computing the value in
different units b$ the recipients is greater than the cost of computing>including the value b$ thesender.
Hxample: =onsider the issue of prices and currenc$ conversion:
<prie>
<8SD>'+.,2</8SD>
</prie>
(f the recipients of the A!" *ant to convert the same price into pounds sterling, it's not a
straightfor*ard fixed conversion rate. (t *ill depend upon multiple factors such as the date that
the transaction took place and an$ conversion charges that appl$.
<prie>
<8SD>'+.,2</8SD>
<89:>1&.'2</89:>
</prie>
(f this is recording a transaction and the conversion rate is not discoverable b$ the recipients,
then expressing the value in different units into the instance is imperative.
The transaction costs involved in discovering the euivalences are sometimes higher than the
cost of carr$ing the data in the first place.
@hen deciding *hether to replicate information, the determinant is this:
-rovide the data in multiple different units *hen
the cost of replication is less than the cost of
computation *hen the data is rereferenced.
A)no.ledgements
Thanks to the follo*ing people for participating in these Eportable data componentE discussions:
-aul )irkel
!ike )renner &urt =agle
7/21/2019 Portable Data Components
http://slidepdf.com/reader/full/portable-data-components 10/10
Ton$ =onsidine
-ete =ordell
%ohn =o*an 1oger =ostello
!ichael Fletcher
!ukul Mandhi tephen Mreen
%asen %acobsen
)ill &earne$ &en "aske$
5melia "e*is
Frank !anola
)ob atale "iam Nuin
imon t. "aurent