• Keine Ergebnisse gefunden

Extended Links – forward and inverse Perspective

AddBody(ai, B),ifai∈ELEM

ai, ifai∈ATTR∪TEXT

– place=replace⇒result= [B, . . . , B

| {z }

mtimes

]

– place=fuse⇒result= [CombineBodies(A, B)].

6.2 Extended Links – forward and inverse Per-spective

The out-of-line definition and 3rd party semantics of linkbases forforwardand inverse perspectives as described in Section 4.1 cannot be mapped with the ADT operators defined up to here, sinceγ andγX are based on mapping links

6.2. EXTENDED LINKS –FORWARDANDINVERSEPERSPECTIVE 71 inline. One idea is to expand the traversal functionsφandφwith an additional linkbase parameterLB(to provide it with the necessary linkbase information), and to apply them to the embedding resource (from forforward,toforinverse).

φ(LB)and φ(LB) traverse an XLinked document, expanding Simple Links, and verifying at the same time if the traversed node is referenced by a locator in the linkbase LB. If the locator is an arc’s from-locator, evaluate the arc’s forward perspective. If the locator is an arc’s to-locator, do the same with the arc’s inverse perspective.

6.2.1 Placement Value determines Processing Order

Now, with the knowledge of the mapping operators γL andγR, DoPlacement, and DoCard and with knowledge of the meaning of L/R, placement and car-dinality directives, but before starting with the formal details of the mapping, let’s have a short – and less formal2– look at theplacementdirective, and its im-pact on the order of operator applications to the data model, since the value of theplacement directive(insert,fuse,replace) determines the order of processing operations. Let nodebe a single node identified by the from-locator f romloc, arcthe arc element, andtolocthe to-locator.

• Forforward perspective withplace∈ {insert,replace}the processing order is: DoPlacement(DoCard([[node]],

γL(arc, γL(toloc, γR(toloc))), card), place) In words:

1. evaluate the to-locator’s XPointer result and process it with the R-directive (γR).

2. process the to-locator’s result with the to-locator element (γL).

3. process the previous result with the arc element (γL).

4. apply the cardinality to the node identified by the from-locatornode and the previous result (DoCard).

1-1 builds pairs of node one node/element body from the previous result (duplicatingnode). 1-nbuilds one tuple consisting ofnodeand the complete previoustoside result.

Allowed combinations: for insert, 1-1 and 1-n (default) is allowed.

Forreplace, only1-nis allowed.

5. apply the placement to each pair. The placement operator DoPlace-mentconcatenates each of these pairs (of nodelists). Each pair con-sists of a list of from-nodes and a list of to-nodes. Let’s assume the perspective isforward: then, for each pair, the to-nodes are then (i) made children of, (ii) fused with, or (iii) replacing the from-nodes. In

2For reasons of readability, buckets are not considered in the results ofγLandγRas they are given here. For the formal definition of the mapping involving also the bucket results, see Section 6.2.3 later in this chapter.

inverseperspective, the same is done with from and to interchanged.

Inrelationperspective, no placement is done at all.

• For place=fuse, let againnode be a single node identified by the from-locator. The processing order is:

γL(arc,DoPlacement(DoCard([Body(node)], γL(toloc, γR(toloc)), card), place)) In words:

1. evaluate the to-locator’s XPointer result and apply the R-directive (γR).

2. process the to-locator’s result with the to-locator element (γL). For fuse, L/R-directives are fixed todrop-element insert-bodies.

3. apply the cardinality to the from-node’s body and the previous result (DoCard). Allowed combinations for fuse: 1-1and1-n(default).

4. implement the fuseplacement: process the previous result with the arc element (γL), with its L/R-directive set to dup-arc-elem. The effect is, the arc element is wrapped around each pair of bodies (Body(node),tolocresultbodies)).

5. the original from-nodenodeis replaced with the previous results.

After having the above as a “big picture” in mind, we can plunge into the gory details of the mapping. In the following, the signatures and definitions forφ(LB)

andγ(LB) are given for theforward perspective: a physical document instance is traversed withφ(LB). If a traversed node is part of a from-locator referenced by an arc, and if both the arc and the locator are contained in the linkbase LB, then γ(LB) is applied to that node, which combines the node with the arc result (using insert, replace or fuse), and blends the combined result back into the instance, replacing the original node.

Theinverseperspective is completely symmetric toforward(with only from-and to-locators interchanged). Thus, it is omitted here.

6.2.2 Signature and Definition of φ

(LB)

Signature:

φ(LB):NODE→NODELIST×NODELIST φ(LB)(node)→(newnodelist, bucket) Definition:

φ(LB)(node) =?

• nodeis a – yet unresolved – Simple Link element:

φ(LB)(node) = (result, bucket) with (result, tmpbucket1) =φ(LB)(tmpresult) (tmpresult, tmpbucket2) =φ(node) bucket=tmpbucket1◦tmpbucket2.

6.2. EXTENDED LINKS –FORWARDANDINVERSEPERSPECTIVE 73

• nodeisnot an unresolved Simple Link element ANDnodeis contained in thexlink:href XPointer expression of from-locatorloc (inforward perspec-tive) or to-locatorloc(ininverseperspective) of at least one arcarcin the Extended Link elementextlinkin the linkbaseLB3:

φ(LB)(node) = (newnodelist, bucket)

with (newnodelist, tmpbucket1) =φ(LB)(Flat(nodelistlist)) (nodelistlist, tmpbucket2) =γ(LB)(extlink, arc, loc, node) bucket=tmpbucket1◦tmpbucket2

• else:

– node∈ELEM:

φ(LB)(node) = ([newnode], bucket) newnode=Elem(N ame(node), result) (result, bucket) =φ(LB)(Body(node)) – node∈TEXT∪ATTR:

φ(LB)(node) = (node,[]).

Definition of φ(LB):NODELIST→NODELIST×NODELIST:

φ(LB)([n1, . . . , nk]) = (result1◦resultrest, bucket1◦bucketrest) with (result1, bucket1) =φ(LB)(n1)

(resultrest, bucketrest) =φ(LB)([n2, . . . , nk]) φ(LB)([]) = ([],[]).

6.2.3 Signature and Definition of γ

(LB)

Signature:

γ(LB):ELEM×ELEM×NODE×STRING→NODELISTLIST×NODELIST

γ(LB)(extlink, arc, node, perspective)7→(nodelistlist, bucket) Definition:

γ(LB)(extlink, arc, node, perspective) = (nodelistlist, bucket) with:

• ifperspective=dbxlink:forward:

loc=Loc2Simple(extlink, arc,”xlink:to”)

3If there are multiple arcs referencing the node, or one single arc referencing the node via multiple locators, the view defined by the linkbase is said to beconcurrent. For the treatment of concurrent view definitions, please refer to Section 6.3.

• ifperspective=dbxlink:inverse:

loc=Loc2Simple(extlink, arc,”xlink:from”) (locresult, locbucket) =γLR(loc)

(arcparam, card, place) =GetArcDirectives(arc) newarc=Arc2Simple(extlink, arc, perspective) nodelistlist=?

• place∈ {insert,replace}:⇒

– ifnode∈TEXT∪ATTR⇒nodelistlist= [[node]], bucket= [].

(you can’t insert anything into a text or attribute node) – ifnode∈ELEM: ⇒

nodelistlist=

DoPlacement(DoCard([[node]], arcresult, card), place) with (arcresult, bucket1) =γL(newarc, locresult)

(locresult, bucket2) =γLR(loc) and

bucket=bucket1◦bucket2.

Allowed cardinality directive values: 1-n(default) and1-1forplace= insert, 1-n(fixed) forplace=replace.

• place=fuse:⇒

(nodelistlist, bucket1) =φ(LB)(arcresult) with

(arcresult, bucket2) =

γL(newarc, placementresult) ifplacementresult6= []

([],[]) else

placementresult=DoPlacement(DoCard([Body(node)], locresult, card), place) (locresult, bucket3) =γLR(loc)

and

bucket=bucket1◦bucket2◦bucket3.

6.3 Three Kinds of Transparency for 3rd Party