27
XML-Tuples & XML-Spaces V0.7 By David “Uncle Dave” Moffat Presented by: Shurug Al-Khalifa

XML-Tuples & XML-Spaces V0.7

  • Upload
    belita

  • View
    182

  • Download
    7

Embed Size (px)

DESCRIPTION

XML-Tuples & XML-Spaces V0.7. By David “Uncle Dave” Moffat. Presented by: Shurug Al-Khalifa. Outline. Overview of Tuple Spaces and XML-Spaces. Basic XML-Spaces & XML-Tuples operations. Database operations on XML-Spaces. Extended Database Queries on XML-Spaces. Introduction. - PowerPoint PPT Presentation

Citation preview

Page 1: XML-Tuples &  XML-Spaces  V0.7

XML-Tuples & XML-Spaces

V0.7

By David “Uncle Dave” Moffat

Presented by:Shurug Al-Khalifa

Page 2: XML-Tuples &  XML-Spaces  V0.7

2

Outline

• Overview of Tuple Spaces and XML-Spaces.

• Basic XML-Spaces & XML-Tuples operations.

• Database operations on XML-Spaces.

• Extended Database Queries on XML-Spaces.

Page 3: XML-Tuples &  XML-Spaces  V0.7

3

Introduction

• Implementation of tuples and tuple-spaces using XML.• Tuple list of values (“Sam”, 7, 48.1).• Tuple Space public repository that contains

tuples.• Template tuple set up for matching.• Using XML for the tuples and the commands.

Page 4: XML-Tuples &  XML-Spaces  V0.7

4

Definitions

• XML-tuple list of data fields in an XML format.

• Data field XML-tagged data. <name> Ralph </name>• XML-tuple field values are strings.• XML-space tuple space with XML tuples.• An XML-space:

– Referenced by a name.– Located on a server.

Page 5: XML-Tuples &  XML-Spaces  V0.7

5

Creating and Communicating with an XML-Space• “do” method.

• Commands and parameters expressed in XML.

XMLSpace xs = new XMLSpace (“MySpace”,“server.mine.org”);

Page 6: XML-Tuples &  XML-Spaces  V0.7

6

Writing XML-Tuples to an XML-SpaceString strTuple=“<write>”+

“ <name>Ralph</name>”+“ <age>33</age>”+“ <weight>190.7</weight>”+“</write>”;

String strResult;strResult=xs.do(strTuple);

• Returns with <tuple>• If error, message with <error>

Page 7: XML-Tuples &  XML-Spaces  V0.7

7

Writing Several XML-Tuples at Once

• Concatenate several <write> into one string.<write> <name>Ralph</name>

<age>33</age><weight>190.7</weight>

</write><write> :</write>

Page 8: XML-Tuples &  XML-Spaces  V0.7

8

Matching XML-Tuples

• Create a template.• Template XML-Tuple where fields may or

may not have value in them.

Template Tuple Fields Same fields with or without values Fields with values Same fields with exact same values Empty field <abc/> Empty field <abc/> or <abc></abc> Tag with attribute Same attribute with or without value Tag with attribute & value Same attribute with the same value Fields in a certain order Same fields in the same or different

order

Page 9: XML-Tuples &  XML-Spaces  V0.7

9

Reading XML-Tuples from an XML-Space• Read only.• Match a template.<read>

<name/><age>33</age><weight/>

</read>• Returns with <tuple>• If not Found, NULL is returned.• If error, message with <error>

Page 10: XML-Tuples &  XML-Spaces  V0.7

10

Reading XML-Tuples from an XML-Space• Read and remove.• Match a template.<take>

<name/><age>33</age><weight/>

</take>• Returns with <tuple>• If not Found, NULL is returned.• If error, message with <error>

Page 11: XML-Tuples &  XML-Spaces  V0.7

11

Reading XML-Tuples from an XML-Space• If client has to find a match.• Read <waitToRead>• Read and remove <waitToTake>

• xs.do returns:• Tuple if a match is found.• If a match is not found, waits until tuple exists then returns it.

Page 12: XML-Tuples &  XML-Spaces  V0.7

12

Reading Several XML-Tuples at Once• Read only.• Match a template.<scan> <name/>

<age>33</age><weight/>

</scan>• Returns list of tuples with <tuple>• If not Found, NULL is returned.• If error, message with <error>

Page 13: XML-Tuples &  XML-Spaces  V0.7

13

Reading Several XML-Tuples at Once• Read and remove.• Match a template.<scanTake> <name/>

<age>33</age><weight/>

</scanTake>• Returns list of tuples with <tuple>• If not Found, NULL is returned.• If error, message with <error>

Page 14: XML-Tuples &  XML-Spaces  V0.7

14

Counting the Number of Matching XML-Tuples• Match a template.<count> <name/>

<age>33</age><weight/>

</count>

• Returns number of tuples found with <count>• If error, message with <error>

Page 15: XML-Tuples &  XML-Spaces  V0.7

15

Registering for XML-Space Events

• Event operation on an XML-space.

1. XMLSpaceListener interface.2. Register as a Listener.3. Give a template to the space.

Page 16: XML-Tuples &  XML-Spaces  V0.7

16

Registering for XML-Space Events

1. XMLSpaceListener interface.

Interface XMLSpaceListener { handleXMLSpaceEvent(String tuple,

String space, String host, long lNum, boolean bErr);

}

• If error, message with <error> in “tuple”.

Page 17: XML-Tuples &  XML-Spaces  V0.7

17

Registering for XML-Space Events

2. Register as a Listener.3. Give a template to the space.

xs.addXMLSpaceListner(this,tplt)

• Can register for different operations and templates

Template

Page 18: XML-Tuples &  XML-Spaces  V0.7

18

XML-Space Queries

• Basic query = scan<query>

<name/><age>33</age><weight/>

</query>• Returns a tuple or a list of tuples with <tuple>• If not Found, NULL is returned.• If error, message with <error>

Page 19: XML-Tuples &  XML-Spaces  V0.7

19

ANDing XML-Space Queries

• Match with two given query templates.<andQuery> <query>

: </query> <query>

: </query></andQuery>• Returns a tuple or a list of tuples with <tuple>• If not Found, NULL is returned.• If error, message with <error>

Page 20: XML-Tuples &  XML-Spaces  V0.7

20

ORing XML-Space Queries

• Match with one or both given query templates. <orQuery> <query>

: </query> <query>

: </query></orQuery>• Returns a tuple or a list of tuples with <tuple>• If not Found, NULL is returned.• If error, message with <error>

Page 21: XML-Tuples &  XML-Spaces  V0.7

21

Range Queries

• Match with values within template range. <rangeQuery> <query>

: </query> <query>

: </query></rangeQuery>• Returns a tuple or a list of tuples with <tuple>• If not Found, NULL is returned.• If error, message with <error>

Upper Limit

Lower Limit

Page 22: XML-Tuples &  XML-Spaces  V0.7

Nested Queries

<orQuery> <andQuery>

<query> :</query><query> :</query>

</andQuery> <rangeQuery>

<query> :

</query>

<query> :

</query>

</rangeQuery></orQuery>

Page 23: XML-Tuples &  XML-Spaces  V0.7

23

XML-Space Transactions

• Used to perform an operation only if it is successful.<transaction/><write> :</write><write> :</write>• Everything is OK <commit/>• Anything is unsuccessful <abort/>

Page 24: XML-Tuples &  XML-Spaces  V0.7

24

Matching to Different “Depths”

• A field: - have content but not subfields.<age>33</age>

- be Null and have subfields. <name>

<first>Karl</first>

<last>Martin</last ></name>

- have content and subfields. <phone>123 456 789

<ext>221</ext></phone>

Page 25: XML-Tuples &  XML-Spaces  V0.7

25

Partial XML-Tuple Templates

• Partial Template does not specify all the fields or the subfields.

<name/><address> <city>Ann Arbor</city></address><phone> <ext/></phone>

Page 26: XML-Tuples &  XML-Spaces  V0.7

26

Partial XML-Tuple Templateswith Wildcards• Used to match upper-level fields of template.• Breadth-wise <*/>

<address><city>Ann

Arbor</city> </address>

• Depth-wise <*> <address>

<city>Ann Arbor</city> </address> </*>

Page 27: XML-Tuples &  XML-Spaces  V0.7

27

Conclusion

• Tuple Spaces and XML-Spaces.

• Operations on XML-Spaces & XML-Tuples.

• Querying XML-Spaces.