a generic algorithm for merging sgml/xml instances. design and implementation for the use case:...

31
A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive Industry. Gerald Manger, Development Engineer. 25.05.2001, Berlin.

Upload: luke-cummings

Post on 18-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

A Generic Algorithm for Merging SGML/XML Instances.

Design and Implementation for the Use Case:

Function Documentation of Control Unit Software

in Automotive Industry.

Gerald Manger, Development Engineer.

25.05.2001, Berlin.

Page 2: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

- V-Model ECU-Software Development Process

- Data Model MSRSW.DTD for ECU-Software Documentation

- Function Documentation Process eDoc

- Intuitive demands for tree based instance merging

- Algorithm

- Examples

- Demonstration: Implementation SIGMA of Algorithm

Overview

Page 3: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Requirements

ECU Software ProcessV-Model (simplified)

Specification

Implementation

Calibration

Test

Inte

grat

ion

t

Single Functions

Components

Functionalities

Decom

position

Subject: Parallel Documentation

Page 4: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

ECU-Software DocumentationData Model MSRSW.DTD

Calibration

Function Specification

Implementation

Function Simulator

Page 5: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Process StepsFunctional

Requirements

export

Partially filled InstancesM

SR

SW

Content Management System

EDMPDM

Specification,Design,

Implementation

export

MS

RS

W

Calibration

export

MS

RS

W

Analysis

exportM

SR

SW

Catalog-Maker

Aggre-gation

Container-Catalog

eDoc Process PhasesControl Unit Software Development

Page 6: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

CC-Interpreter

eDoc ModulesECU Software Documentation Process

GenericMerger

ConverterReq

uire

men

tsC

alib

ratio

n

HT

ML,

H

TM

L-H

elp

PD

F

FD

publish

Intranet

MS

RS

WM

SR

SW

edit configure aggregate

Vivace

MSRSW 1.1.0

Metapage

MSRSW 2.xx

Metahelp

MSRSW 1.1.0

MS

RS

W

format

EDM/PDM

ConfigurationPRG

MS

RS

WC

CA

SA

P2

,U

VD

an

yMSRSW

Custom-Tools

MSRSW

Page 7: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Tree-representation

SG M L/XM L-Source Instances

SG M L/XM L-Target Instance

-A lgorithm

Source Trees Target Tree

Page 8: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example of a -tree representation

<CHAPTER ID="CHP1">

This Chapter consists of ...

<CHAPTER ID="CHP1.1">

<?xm-replace-text {chapter}>

This Chapter describes...

</CHAPTER>

<CHAPTER ID="CHP1.2">

In opposite to Chapter 1.1,

this Chapter describes...

</CHAPTER>

</CHAPTER>

Type:ELEMENTGID:CHAPTERID="CHP1"

Type:STRING"This Chapter

consists of..."

TYPE:PIxm-replace-text

{chapter}

Type:STRING"This Chapterdescribes..."

Type:STRING"In opposite to

Chapter 1.1, thisChapter describes..."

Type:ELEMENTGID:CHAPTERID="CHP1.1"

Type:ELEMENTGID:CHAPTERID="CHP1.2"

Page 9: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Merging -trees

A

T 1

B 3 B 2

I2

B 4

I4

B 5

I5

E 1C 1 G 1 H 1

T 9 T 7 T 8

T 6 T 11 T 12I1 I3

T 5 T 10

G 2 H 2

T 13 T 14

C?,<!ELEMENT A - - ( B*, )>B, (G, H)* ((D,Z*)|E),

A

D 1

T 2T 1

C 1 Z 2

J2

T 4

B 1

I1

T 5

B 2

I2

T 6

G 1

T 7

H 1

T 8

Z 1

J1

T 3

<!ELEMENT A - - (C?, ((D,Z*)| E) ,B,B*, (G,H)*)>

A

E 1

T 9

B 3

I3

T 10

B 4

I4

T 11

B 5

I5

T 12

G 2

T 13

H 2

T 14

<!ELEMENT A -- (C?,((D,Z*)|E),B,B*)>

<!ELEMENT B -- (I)*>

<!ELEMENT Z -- (J)>

<!ELEMENT (C,D,E,I,J) -- (#PCDATA)>

Page 10: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm -path of a node k

p(k) = "A/B[BID=a]/C/D[DID=b]"

k

Type: ELEMENTGID=A

Type: ELEMENTGID=BBID="a"

Type: ELEMENTGID=A

Type: STRING"Text A2..."

Type: ELEMENTGID=A

Type: STRING"Text A1..."

Type: ELEMENTGID=C

Type:ELEMENTGID=DDID="b"

Type: STRING"Text D ..."

Page 11: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Definitions

actual Document Type Definition (DTD) all sources are valid

instances of

gid(k): returns the generic identifier (gid) of a node k

of type ELEMENT

p(k): List of all -source nodes having the same -path as k

(gid(k)): content model of the element corresponding to

node k

m(gid(k)): -modelgroup no. m in content model (gid(k))

of node k

Page 12: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm -modelgroups

<!ELEMENT A - - ((B,C)?,(D|E),(F,G)*)>

1(gid(A)) = (B,C)?,

2(gid(A)) = (D|E), 3(gid(A)) = (F,G)*

<!ELEMENT A - - ((B,C)+ | (D,(E | F))*)>

1(gid(A)) = (gid(A))

<!ELEMENT A - - ((B,C)*,D)*>

1(gid(A)) = (gid(A))

Page 13: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Intuitive Demands for

- The target instance has to be valid concerning DTD

- The source instances are represented by their corresponding

-source trees.

- The -target tree is later converted to the target instance.

- Optional or mandatory - modelgroups imply the creation of

merge-priorities.

Page 14: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Intuitive Demands for

- All nodes of the highest merge-priority -source tree shall

be contained in the -target tree.

- Hence, the -target tree has to contain the root node of the

highest priority -source tree.

- ELEMENT-type child nodes kc of a -source tree node ks may

only be regarded as potential child nodes of an actual -target tree node k if ks has the same -path as k.

- These Nodes kc are appended below k grouped by

instantiations of each m(gid(k))).

Page 15: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Intuitive Demands for

- A target instance with an ID-attribute value existing more

than once is not valid.

- A target instance with IDREF(S)-attribute values pointing to

not existing ID-attribute values is not valid.

Page 16: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm getInsertType(k)

Input:

actual -target tree node k with type(k) = ELEMENT

Output:

insert_type {ONLY_FROM_ORIGIN, FROM_ALL_SOURCES}

The function getInsertType(k) provides information whether the

subtree of a -target tree node k can be copied directly from its

origin node orig(k).

Page 17: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm without considering ID-attributes

Input:-source trees tr(S1),..., tr(SN), having no ID-attributes,

S1,...,SN valid concerning

Output:

-target tree

Page 18: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm without considering ID-attributes

1. := root(tr(SN))

2. k := root(tr(SN))

3. Traverse top-down, left-right. Let k be the actual -target tree node.

1. IF type(k) {PI, STRING, COMMENT} THEN

1. Copy all contents (i.e. the node text) of orig(k) beneath k.

2. Proceed traversing top-down, left-right.

2. ELSE

1. IF getInsertType(k) = ONLY_FROM_ORIGIN THEN

1. Append subtree of orig(k) beneath k.

2. Stop traversing the subtree of k. Proceed traversing

2. ELSE calculate p(k). For all

m(gid(k)) in (gid(k)) do:

1. IF occ(m(gid(k))) (*,+), THEN

Append contentsAt(p(k),

m(gid(k))) beneath k.

2. ELSE Append first_ex_contentsAt(p(k),

m(gid(k))) beneath k.

Page 19: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example: Step 1

<!ELEMENT A - - (E,B*)>

<!ELEMENT B - - (D)>

<!ELEMENT C - - (F?,(#PCDATA))>

<!ELEMENT (D,F) - - (#PCDATA)>

<!ELEMENT E - - (C* ,D*)>

B 2

Text 7

E 2

D 4C 2

Text 5

C 3

Text 6

A 2k2 :=

B 1

Text 4

D 2D 1C 1

Text 0

Text 1F 1

Text 2 Text 3

E 1

D 3

A 1k1 :=

Source T ree 1 Source T ree 2

Step 1: T arget T ree

actualT arget T ree Node k

A 2

Page 20: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example: Step 2

<!ELEMENT A - - (E,B*)>

<!ELEMENT B - - (D)>

<!ELEMENT C - - (F?,(#PCDATA))>

<!ELEMENT (D,F) - - (#PCDATA)>

<!ELEMENT E - - (C* ,D*)>

next actualTarget Tree Node

B 1E 2 B 2

A 2

actual Target TreeNode k

Target Tree

B 2

Text 7

E 2

D 4C 2

Text 5

C 3

Text 6

A 2

B 1

Text 4

D 2D 1C 1

Text 0

Text 1F 1

Text 2 Text 3

E 1

D 3

A 1

Source T ree 1 Source T ree 2

Page 21: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example: Step 3

<!ELEMENT A - - (E,B*)>

<!ELEMENT B - - (D)>

<!ELEMENT C - - (F?,(#PCDATA))>

<!ELEMENT (D,F) - - (#PCDATA)>

<!ELEMENT E - - (C* ,D*)>

B 1E 2B 2

C 1 C 2 C 3 D 1 D 2

actual Target Tree Node k

next actualTarget Tree Node

A 2

Target Tree

B 2

Text 7

E 2

D 4C 2

Text 5

C 3

Text 6

A 2

B 1

Text 4

D 2D 1C 1

Text 0

Text 1F 1

Text 2 Text 3

E 1

D 3

A 1

Source T ree 1 Source T ree 2

Page 22: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example: Step 4

<!ELEMENT A - - (E,B*)>

<!ELEMENT B - - (D)>

<!ELEMENT C - - (F?,(#PCDATA))>

<!ELEMENT (D,F) - - (#PCDATA)>

<!ELEMENT E - - (C* ,D*)>

B 1E 2 B 2

C 1 C 2 C 3 D 1D 2

actual Target TreeNode k

next actual TargetTree Node

T ext 0

T ext 1F 1

A 2

Target Tree

B 2

Text 7

E 2

D 4C 2

Text 5

C 3

Text 6

A 2

B 1

Text 4

D 2D 1C 1

Text 0

Text 1F 1

Text 2 Text 3

E 1

D 3

A 1

Source T ree 1 Source T ree 2

Page 23: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example: Step 8

<!ELEMENT A - - (E,B*)>

<!ELEMENT B - - (D)>

<!ELEMENT C - - (F?,(#PCDATA))>

<!ELEMENT (D,F) - - (#PCDATA)>

<!ELEMENT E - - (C* ,D*)>

B 1E 2 B 2

C 1 C 2 C 3 D 1D 2

T ext5T ext6 T ext2 T ext3

actual Target Tree Node k

next actualTarget Tree Node

T ext 0

T ext 1F 1

A 2

Target Tree

B 2

Text 7

E 2

D 4C 2

Text 5

C 3

Text 6

A 2

B 1

Text 4

D 2D 1C 1

Text 0

Text 1F 1

Text 2 Text 3

E 1

D 3

A 1

Source T ree 1 Source T ree 2

Page 24: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example: Step 9

<!ELEMENT A - - (E,B*)>

<!ELEMENT B - - (D)>

<!ELEMENT C - - (F?,(#PCDATA))>

<!ELEMENT (D,F) - - (#PCDATA)>

<!ELEMENT E - - (C* ,D*)>

B 1E 2 B 2

C 1 C 2 C 3 D 1 D 2

T ext5T ext6 T ext2 T ext3

actual Target Tree Node k

next actualTarget Tree Node

T ext 0

T ext 1F 1

A 2

D 3

T ext4

Target Tree

B 2

Text 7

E 2

D 4C 2

Text 5

C 3

Text 6

A 2

B 1

Text 4

D 2D 1C 1

Text 0

Text 1F 1

Text 2 Text 3

E 1

D 3

A 1

Source T ree 1 Source T ree 2

Page 25: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example: Finished

<!ELEMENT A - - (E,B*)>

<!ELEMENT B - - (D)>

<!ELEMENT C - - (F?,(#PCDATA))>

<!ELEMENT (D,F) - - (#PCDATA)>

<!ELEMENT E - - (C* ,D*)>

B 1E 2B 2

A 2

C 1 C 2 C 3 D 1 D 2

T ext5 T ext6 T ext2 T ext3

D 3

T ext4 T ext7

D 4

T ext 0

T ext 1F 1

Target Tree

B 2

Text 7

E 2

D 4C 2

Text 5

C 3

Text 6

A 2

B 1

Text 4

D 2D 1C 1

Text 0

Text 1F 1

Text 2 Text 3

E 1

D 3

A 1

Source T ree 1 Source T ree 2

Page 26: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm Example: ID-conflict of type 1

<!ELEMENT A - - (B,C,D)>

<!ELEMENT B - - (E)*>

<!ELEMENT (C,D,F) - - (#PCDATA)>

<!ELEMENT E - - (F)*>

<!ATTLIST E ID ID #REQUIRED>

A 1

B 1 C 1 D 1

T ext3 T ext4

E 1

ID ="A1"

T ext2T ext1

F 1F 2

Source Tree1 Source Tree2 Source Tree3

A 2

B 2 C 2 D 2

T ext7 T ext8

E 2

ID ="A2"

T ext6T ext5

F 3F 4

A 3

B 3 C 3 D 3

T ext11 T ext12

E 3

ID ="A2"

T ext10T ext9

F 5F 6

A 3

B 3

E 3

ID = "A 2 "

E 1

ID = "A 1 "

Text2Text1

F 1 F 2

C 3D 3

Text11 Text12

Text10Text9

F 5 F 6

Text6Text5

F 3 F 4

T arget T ree

Page 27: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm ID-conflict of type 2

<!ELEMENT A - - (Y?,B,Z?) >

<!ELEMENT B - - (C* ,D*) >

<!ELEMENT (C,D,E,F) - - (#PCDATA) >

<!ATTLIST C ID ID #REQUIRED >

<!ATTLIST D ID ID #REQUIRED >

<!ELEMENT Y - - (E)* >

<!ELEMENT Z - - (F) >

<!ATTLIST E ID ID #REQUIRED >

<!ATTLIST F ID ID #REQUIRED >

T ext2 T ext3

C 2

ID =A5

T ext6 T ext7

C

=:k1 =:k2

E 3

ID =A4

T ext5

D 1

ID =A3

C 1

ID =A4

F 1

ID =A6

T ext1

E 2

ID =A2

E 1

ID =A1

T ext4

=:kx =:ky

=:k3

Source Tree1 Source Tree2

A 1 A 2

Y 1 B 1 B 2 Z 1

Page 28: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm ID-conflict of type 2 with valid target tree

<!ELEMENT A - - (B,C,E?)>

<!ELEMENT B - - (D)>

<!ELEMENT C - - (D)>

<!ELEMENT D - - (#PCDATA)>

<!ATTLIST D ID ID #REQUIRED>

<!ELEMENT E - - (#PCDATA)>

A 1

B 1 C 1 E 1

T ext3

T ext1

D 1

ID ="A1"

T ext2

D 2

ID ="A2"

A 2

B 2

T ext4

D 3

ID ="A2"

C 2

D 4

ID ="A3"

T ext5

Source Tree1 Source Tree2

A 2

B 2 C 2 E 1

Text3

Text4

D 3

ID = "A 2 "

Text5

D 4

ID = "A 3 "

T arget T ree

Page 29: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Algorithm IDREF-conflict

<!ELEMENT A - - (B,C,D)>

<!ELEMENT B - - (E)*>

<!ELEMENT (C,D,E) - - (#PCDATA)>

<!ATTLIST D ID ID #REQUIRED>

<!ATTLIST E IDR IDREF #REQUIRED>

A 1

B 1 C 1 D 1

ID ="A1"

T ext2 T ext3

T ext1

E 1

ID R ="A1"

A 2

B 2 C 2 D 2

ID ="A2"

T ext5 T ext6

T ext4

E 2

ID R ="A2"

Source Tree1 Source Tree2

A 2

B 2 C 2D 2

ID ="A2"

T ext5 T ext6

T ext4

E 2

ID R ="A2"

T ext1

E 1

ID R ="A1"

Target Tree

Page 30: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Implementation SIGMADemonstration

Page 31: A Generic Algorithm for Merging SGML/XML Instances. Design and Implementation for the Use Case: Function Documentation of Control Unit Software in Automotive

Contact

http://www.msr-wg.de

[email protected]