XML-Tuples & XML-Spaces V0.7

Preview:

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

XML-Tuples & XML-Spaces

V0.7

By David “Uncle Dave” Moffat

Presented by:Shurug Al-Khalifa

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.

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.

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.

5

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

• Commands and parameters expressed in XML.

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

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>

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>

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

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>

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>

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.

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>

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>

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>

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.

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”.

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

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>

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>

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>

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

Nested Queries

<orQuery> <andQuery>

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

</andQuery> <rangeQuery>

<query> :

</query>

<query> :

</query>

</rangeQuery></orQuery>

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/>

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>

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>

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> </*>

27

Conclusion

• Tuple Spaces and XML-Spaces.

• Operations on XML-Spaces & XML-Tuples.

• Querying XML-Spaces.