0% found this document useful (0 votes)
180 views

XML Schema Design Patterns

This document discusses and provides examples of four common XML schema design patterns: Russian Doll, Salami Slice, Venetian Blind, and Garden of Eden. It describes the key characteristics of each pattern, including whether elements are global or local, how types and elements are defined and reused, advantages and disadvantages of each pattern, and common use cases. It also mentions that NetBeans provides support for selecting an XML schema design pattern.

Uploaded by

rajeshks117
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
180 views

XML Schema Design Patterns

This document discusses and provides examples of four common XML schema design patterns: Russian Doll, Salami Slice, Venetian Blind, and Garden of Eden. It describes the key characteristics of each pattern, including whether elements are global or local, how types and elements are defined and reused, advantages and disadvantages of each pattern, and common use cases. It also mentions that NetBeans provides support for selecting an XML schema design pattern.

Uploaded by

rajeshks117
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

XML Schema

Design Patterns

1
Popular XML Schema Design
Patterns
 Russian Doll
 Salami Slice
 Venetian Blind
 Garden of Eden

2
Popular XML Schema Design
Patterns
 The patterns vary according to the
number of their global elements or
types.
 You can conveniently classify the four
most common patterns according to
two criteria, namely:
 Ease of use for instance developers
 Ease of reuse for schema developers

3
Russian Doll

4
Russian Doll

 The Russian Doll design contains only


one single global element.
 All the other elements are local.
 You nest element declarations within a
single global declaration

5
Example: Russian Doll
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.sun.com/point/russiandoll"
xmlns:tns="http://schemas.sun.com/point/russiandoll"
elementFormDefault="qualified">

<xsd:element name="Line"> Global element


<xsd:complexType>
<xsd:sequence>
<xsd:element name="PointA">
<xsd:complexType>
<xsd:attribute name="x" type="xsd:integer"/>
<xsd:attribute name="y" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
<xsd:element name="PointB">
<xsd:complexType>
<xsd:attribute name="x" type="xsd:integer"/>
<xsd:attribute name="y" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema> 6
Advantages & Disadvantages

 Advantages
 Contains only one valid root element.
 Could reduce the complexity of
namespace
 Easy to use from instance developer's
point of view
 Disadvantages
 Reuse of elements is limited – not easy to
use from schema developer's point of
view
 Supports single-file schema only
7
Usage

 Russian Doll is the simplest and


easiest pattern to use by instance
developers.
 However, if its elements or types are
intended for reuse, Russian Doll is not
suitable for schema developers.

8
Salami Slide

9
Salami Slice

 All the elements in the Salami Slice


design are global.
 No nesting of element declarations is
required and you can reuse the
declarations throughout the schema.
 You must define all the elements within
the global namespace.

10
Example: Salami Slide
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.sun.com/point/salami"
xmlns:tns="http://schemas.sun.com/point/salami"
xmlns="http://schemas.sun.com/point/salami"
elementFormDefault="qualified">

<xsd:element name="PointA"> Global elements


<xsd:complexType>
<xsd:attribute name="x" type="xsd:integer"/>
<xsd:attribute name="y" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>

<xsd:element name="PointB">
<xsd:complexType>
<xsd:attribute name="x" type="xsd:integer"/>
<xsd:attribute name="y" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>

<xsd:element name="Line">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="PointA"/>
<xsd:element ref="PointB"/>
</xsd:sequence> 11
Advantages & Disadvantages

 Advantages
 Contains all reusable elements.
 Supports reuse of elements from other
documents.
 Disadvantages
 Exposes the complexity in namespace.

12
Venetian Blind

13
Venetian Blind

 The Venetian Blind design contains only


one global element.
 All the other elements are local.
 You nest element declarations within a
single global declaration by means of
named complex types and element
groups.
 You can reuse those types and groups
throughout the schema and must define
only the root element within the global
namespace.
14
Example: Venetian Blind
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.sun.com/point/venetianblind"
xmlns:tns="http://schemas.sun.com/point/venetianblind"
xmlns="http://schemas.sun.com/point/venetianblind"
elementFormDefault="qualified">

<xsd:complexType name="PointType">
<xsd:attribute name="x" type="xsd:integer"/>
<xsd:attribute name="y" type="xsd:integer"/>
</xsd:complexType>

<xsd:element name="Line"> Global element


<xsd:complexType>
<xsd:sequence>
<xsd:element name="PointA" type="PointType"/>
<xsd:element name="PointB" type="PointType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>

15
Advantages & Disadvantages

 Advantages
 Contains only one single root element.
 Allows reuse for all the types and the
single global element.
 Allows multiple files

 Disadvantages
 Limits encapsulation by exposing types.

16
Usage

 Because it has only one single root


element and all its types are reusable,
Venetian Blind is suitable for use by
both instance developers and schema
developers.
 Venetian Blind is considered as an
extension of Russian Doll, in which all the
types are defined globally.

17
Garden of Eden

18
Garden of Eden

 The Garden of Eden design is a


combination of Venetian Blind and
Salami Slice.
 You define all the elements and types
in the global namespace and refer to
the elements as required.

19
Example: Garden of Eden
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://schemas.sun.com/point/gardenofeden"
xmlns="http://schemas.sun.com/point/gardenofeden"
elementFormDefault="qualified">

<xsd:complexType name="PointType">
<xsd:attribute name="x" type="xsd:integer"/>
<xsd:attribute name="y" type="xsd:integer"/>
</xsd:complexType>

<xsd:complexType name="LineType">
<xsd:sequence>
<xsd:element ref="PointA"/>
<xsd:element ref="PointB"/>
</xsd:sequence>
</xsd:complexType>
Global elements
<xsd:element name="PointA" type="PointType"/>

<xsd:element name="PointB" type="PointType"/>

<xsd:element name="Line" type="LineType"/>


</xsd:schema>
20
Advantages & Disadvantages

 Advantages
 Allows reuse of both elements and types.
 Allows multiple files.

 Disadvantages
 Contains many potential root elements.
 Limits encapsulation by exposing types.
 Is difficult to read and understand.

21
NetBeans Support
on XML Schema
Design Patterns

22
NetBeans XML Schema Design
Support
 Lets you choose a design pattern by
letting you choose
 Scheme of Creating global element
 Scheme of Creating type

 Creating global element


 Create a single global element
 Create Multiple global elements

 Creating type
 Create Type(s)
 Do not Create Type(s)
23
NetBeans XML Schema Design
Support

24
XML Schema
Design Patterns

25

You might also like