Title: XML and NNF
1XML 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.
2XNF Example
NNF with as few schemes as possible
FD Closures NrBeds 4, Cost 4, RoomNr 3,
RoomName 3, GuestName 2,
View 1, GuestNr 1.
Back off by one, when possible.
Result (RoomNr, RoomName, Cost, NrBeds, (View),
(GuestNr, GuestName) )
3DTD(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
4Straightforward Translation
- Main Idea Use the scheme-tree forest directly as
the DTD specification. - Details
- Introduce a root name (e.g. lt!DOCTYPE BandB
gt). - Rename attributes appearing in multiple trees.
- Add the scheme trees as structural elements (e.g.
lt!ELEMENT BandB ((RoomNr, RoomName, ))gt). - Declare all attributes as elements with character
data (e.g. lt!ELEMENT RoomNr (PCDATA)gt).
5Example
(RoomNr, RoomName, Cost, NrBeds (View) (GuestNr,
GuestName) )
lt!DOCTYPE BandB lt!ELEMENT BandB (
( RoomNr, RoomName, Cost, NrBeds, (View),
(GuestNr, GuestName) ))gt lt!ELEMENT
RoomNr (PCDATA)gt lt!ELEMENT RoomName
(PCDATA)gt lt!ELEMENT GuestName
(PCDATA)gt gt ltBandBgt ltRoomNrgt1lt/RoomNrgt
ltRoomNamegtKennedylt/RoomNamegt
ltCostgt90lt/Costgt ltNrBedsgt2lt/NrBedsgt
ltViewgtForestlt/Viewgt ltViewgtSealt/Viewgt
ltGuestNrgt101lt/GuestNrgt
ltGuestNamegtSmithlt/GuestNamegt
ltRoomNrgt2lt/RoomNrgt lt/BandBgt
6A 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. lt!ELEMENT Rooms (RoomNr)gt). - Use XML attributes for key elements (e.g.
lt!ATTLIST RoomNr value CDATA REQUIREDgt).
7Example
Rooms RoomNr, RoomName, Cost, NrBeds
Views View
Guests GuestNr, GuestName
lt!DOCTYPE BandB lt!ELEMENT Rooms (RoomNr)gt
lt!ELEMENT RoomNr (RoomName, Cost, NrBeds,
Views, Guests)gt
lt!ATTLIST RoomNr value CDATA REQUIREDgt
lt!ELEMENT RoomName (PCDATA)gt
lt!ELEMENT Cost (PCDATA)gt lt!ELEMENT
NrBeds (PCDATA)gt lt!ELEMENT Views
(View)gt lt!ELEMENT View EMPTYgt
lt!ATTLIST View value CDATA
REQUIREDgt lt!ELEMENT Guests
(GuestNr)gt lt!ELEMENT GuestNr
(GuestName)gt lt!ATTLIST
GuestNr value CDATA REQUIREDgt
lt!ELEMENT GuestName (PCDATA)gt gt
ltBandBgt ltRoomsgt ltRoomNr value1gt
ltRoomNamegtKennedylt/RoomNamegt
ltCostgt90lt/Costgt ltNrBedsgt2lt/NrBedsgt
ltViewsgt ltView
valueForest/gt ltView
valueSea/gt lt/Viewsgt
ltGuestsgt ltGuestNr value101gt
ltGuestNamegtSmithlt/GuestNamegt
lt/GuestNrgt lt/Guestsgt
lt/RoomNrgt ltRoomNr value2gt
lt/Roomsgt
8A Translation to XML Schema
- XML Schema supersedes DDTs
- 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
9Example
RoomNr, RoomName, Cost, NrBeds
View
GuestNr, GuestName
ltxselement nameRoomNrsgt ltxscomplexTypegt
ltxssequencegt ltxselement
nameRoomNr minOccurs1
maxOccursunboundedgt
ltxscomplexTypegt ltxsallgt
ltxselement nameViewsgt
lt/xselementgt
ltxselement nameGuestNrsgt
lt/xselementgt
lt/xsallgt ltxsattribute
nameRoomNr userequiredgt
ltRoomNrsgt ltRoomNr RoomNr1
RoomNameKennedy NrBeds2
Cost90/gt ltViewsgt ltView
ViewForest/gt ltView ViewSea/gt
lt/Viewsgt ltGuestNrsgt
ltGuestNr GuestNr101 GuestNameSmith/gt
lt/RoomNrsgt
(Full XML-Schema Instance)