xml and nnf

9
XNF: 1 XML and NNF A Standard Form for XML Documents (XNF) • Properties As few hierarchical trees as possible No redundant data values in any tree • Method Model the application as a hypergraph of functional and multi-valued constraints. Make the hypergraph canonical. Transform the canonical hypergraph into an NNF scheme-tree forest with as few trees as possible. Cast the NNF scheme trees into XML DTD / Schema.

Upload: benjamin-wise

Post on 31-Dec-2015

19 views

Category:

Documents


0 download

DESCRIPTION

XML and NNF. A Standard Form for XML Documents (XNF) Properties As few hierarchical trees as possible No redundant data values in any tree Method Model the application as a hypergraph of functional and multi-valued constraints. Make the hypergraph canonical. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: XML and NNF

XNF: 1

XML and NNF

• A Standard Form for XML Documents (XNF)• Properties

– As few hierarchical trees as possible– No redundant data values in any tree

• Method– Model the application as a hypergraph of functional and

multi-valued constraints.– Make the hypergraph canonical.– Transform the canonical hypergraph into an NNF scheme-

tree forest with as few trees as possible.– Cast the NNF scheme trees into XML DTD / Schema.

Page 2: XML and NNF

XNF: 2

XNF Example

GuestNr GuestNameRoomNr

ViewCostRoomName

NrBeds GuestNr GuestNameRoomNr

ViewCostRoomName

NrBeds

Result: (RoomNr, RoomName, Cost, NrBeds, (View)*, (GuestNr, GuestName)* )*

FD Closures: NrBeds: 4, Cost: 4, RoomNr: 3, RoomName: 3, GuestName: 2, View: 1, GuestNr: 1.

Back off by one, when possible.

NNF with as few schemes as possible:

Page 3: XML and NNF

XNF: 3

DTD(Document Type Definition)

• Defines a structure for XML documents• Declarations

– DOCTYPE– ELEMENT

• Structural elements in terms of regular expressions (, * + ? |)

• Elementary elements as Parsable Character DATA (#PCDATA)

– ATTLIST

Page 4: XML and NNF

XNF: 4

Straightforward Translation

• Main Idea: Use the scheme-tree forest directly as the DTD specification.

• Details:– Introduce a root name (e.g. <!DOCTYPE BandB [ … ]>).– Rename attributes appearing in multiple trees.– Add the scheme trees as structural elements (e.g. <!

ELEMENT BandB ((RoomNr, RoomName, … )*)>).– Declare all attributes as elements with character data (e.g.

<!ELEMENT RoomNr (#PCDATA)>).

Page 5: XML and NNF

XNF: 5

Example(RoomNr, RoomName, Cost, NrBeds (View)* (GuestNr, GuestName)* )*

<!DOCTYPE BandB [ <!ELEMENT BandB ( ( RoomNr, RoomName, Cost, NrBeds, (View)*, (GuestNr, GuestName)* )*)> <!ELEMENT RoomNr (#PCDATA)> <!ELEMENT RoomName (#PCDATA)> … <!ELEMENT GuestName (#PCDATA)>]>

<BandB> <RoomNr>1</RoomNr> <RoomName>Kennedy</RoomName> <Cost>90</Cost> <NrBeds>2</NrBeds> <View>Forest</View> <View>Sea</View> <GuestNr>101</GuestNr> <GuestName>Smith</GuestName> <RoomNr>2</RoomNr> …</BandB>

Page 6: XML and NNF

XNF: 6

A More Sophisticated Translation

• Main Idea: Nest the XML according to the scheme-tree structure

• Details– Create concept names for each node (e.g. Rooms).– Identify key elements for nodes (e.g. RoomNr).– Nest according to node names and key elements (e.g. <!

ELEMENT Rooms (RoomNr)*>).– Use XML attributes for key elements (e.g. <!ATTLIST

RoomNr value CDATA #REQUIRED>).

Page 7: XML and NNF

XNF: 7

ExampleRooms: RoomNr, RoomName, Cost, NrBeds

Views: View Guests: GuestNr, GuestName

<!DOCTYPE BandB [ <!ELEMENT Rooms (RoomNr)*> <!ELEMENT RoomNr (RoomName, Cost, NrBeds, Views, Guests)> <!ATTLIST RoomNr value CDATA #REQUIRED> <!ELEMENT RoomName (#PCDATA)> <!ELEMENT Cost (#PCDATA)> <!ELEMENT NrBeds (#PCDATA)> <!ELEMENT Views (View)*> <!ELEMENT View EMPTY> <!ATTLIST View value CDATA #REQUIRED> <!ELEMENT Guests (GuestNr)*> <!ELEMENT GuestNr (GuestName)> <!ATTLIST GuestNr value CDATA #REQUIRED> <!ELEMENT GuestName (#PCDATA)>]>

<BandB> <Rooms> <RoomNr value=“1”> <RoomName>Kennedy</RoomName> <Cost>90</Cost> <NrBeds>2</NrBeds> <Views> <View value=“Forest”/> <View value=“Sea”/> </Views> <Guests> <GuestNr value=“101”> <GuestName>Smith</GuestName> </GuestNr> </Guests> </RoomNr> <RoomNr value=“2”> … </Rooms>…

Page 8: XML and NNF

XNF: 8

A Translation to XML Schema

• XML Schema supersedes DTD’s– Adds data types– Adds keys and uniqueness constraints– Adds power to cardinality constraints– …

• Same basic idea as the sophisticated translation: use keys and nest according to the structure– Generate names automatically– Add cardinality and uniqueness constraints

Page 9: XML and NNF

XNF: 9

ExampleRoomNr, RoomName, Cost, NrBeds

View GuestNr, GuestName

<xs:element name=“RoomNrs”> <xs:complexType> <xs:sequence> <xs:element name=“RoomNr” minOccurs=“1” maxOccurs=“unbounded”> <xs:complexType> <xs:all> <xs:element name=“Views”> … </xs:element> <xs:element name=“GuestNrs”> … </xs:element> </xs:all> <xs:attribute name=“RoomNr” use=“required”> …

<RoomNrs> <RoomNr RoomNr=“1” RoomName=“Kennedy” NrBeds=“2” Cost=“90”/> <Views> <View View=“Forest”/> <View View=“Sea”/> </Views> <GuestNrs> <GuestNr GuestNr=“101” GuestName=“Smith”/> …</RoomNrs>

(Full XML-Schema Instance)