SlideShare una empresa de Scribd logo
1 de 6
Descargar para leer sin conexión
Global versus Local
Table of Contents
               Issue
               Introduction
               Russian Doll Design
               Salami Slice Design
               Russian Doll Design Characteristics
               Salami Slice Design Characteristics
               Venetian Blind Design
               Venetian Blind Design Characteristics
               Best Practice

Issue
When should an element or type be declared global versus when should it be declared local?

Introduction
[Recall that a component (element, complexType, or simpleType) is “global” if it is an
immediate child of <schema>, whereas it is “local” if it is not an immediate child of <schema>,
i.e., it is nested within another component.]

What advice would you give to someone who was to ask you, “In general, when should an
element (or type) be declared global versus when should it be declared local”? The purpose of
this chapter is to provide answers to that question.

Below is a snippet of an XML instance document. We will explore the different design strategies
using this example.

               <Book>
                 <Title>Illusions</Title>
                 <Author>Richard Bach</Author>
               </Book>

Russian Doll Design
This design approach has the schema structure mirror the instance document structure, e.g.,
declare a Book element and within it declare a Title element followed by an Author element:

               <xsd:element name=“Book”>
                 <xsd:complexType>
                   <xsd:sequence>
                     <xsd:element name=“Title” type=“xsd:string”/>
                     <xsd:element name=“Author” type=“xsd:string”/>
                   </xsd:sequence>
                 </xsd:complexType>
               </element>




                                            22
The instance document has all its components bundled together. Likewise, the schema is
designed to bundle together all its element declarations.

This design represents one end of the design spectrum.

Salami Slice Design
The Salami Slice design represents the other end of the design spectrum. With this design we
disassemble the instance document into its individual components. In the schema we define each
component (as an element declaration), and then assemble them together:

               <xsd:element name=“Title” type=“xsd:string”/>
               <xsd:element name=“Author” type=“xsd:string”/>
               <xsd:element name=“Book”>
                 <xsd:complexType>
                   <xsd:sequence>
                     <xsd:element ref=“Title”/>
                     <xsd:element ref=“Author”/>
                   </xsd:sequence>
                 </xsd:complexType>
               </xsd:element>

Note how the schema declared each component individually (Title, and Author) and then
assembled them together (by ref’ing them) in the creation of the Book component.

These two designs represent opposite ends of the design spectrum.

To understand these designs it may help to think in terms of boxes, where a box represents an
element or type:
• The Russian Doll design corresponds to having a single box, and it has nested within it boxes,
  which in turn have boxes nested within them, and so on. (boxes within boxes, just like a
  Russian Doll!)
• The Salami Slice design corresponds to having many separate boxes which are assembled
  together (separate boxes combined together, just like Salami slices brought together in a
  sandwich!)
Let’s examine the characteristics of each of the two designs. (In so doing it will yield insights
into another design.)

Russian Doll Design Characteristics
[1] Opaque content. The content of Book is opaque to other schemas, and to other parts of the
    same schema. The impact of this is that none of the types or elements within Book are
    reusable.
[2] Localized scope. The region of the schema where the Title and Author element declarations
    are applicable is localized to within the Book element. The impact of this is that if the
    schema has set elementFormDefault=“unqualified” then the namespaces of Title and Author
    are hidden (localized) within the schema.




                                                  23
[3] Compact. Everything is bundled together into a tidy, single unit.
[4] Decoupled. With this design approach each component is self-contained (i.e., they don’t
    interact with other components). Consequently, changes to the components will have limited
    impact. For example, if the components within Book changes it will have a limited impact
    since they are not coupled to components outside of Book.
[5] Cohesive. With this design approach all the related data is grouped together into self-
    contained components, i.e., the components are cohesive.
Salami Slice Design Characteristics
[1] Transparent content. The components which make up Book are visible to other schemas,
    and to other parts of the same schema. The impact of this is that the types and elements
    within Book are reusable.
[2] Global scope. All components have global scope. The impact of this is that, irrespective of
    the value of elementFormDefault, the namespaces of Title and Author will be exposed in
    instance documents.
[3] Verbose. Everything is laid out and clearly visible.
[4] Coupled. In our example we saw that the Book element depends on the Title and Author
    elements. If those elements were to change it would impact the Book element. Thus, this
    design produces a set of interconnected (coupled) components.
[5] Cohesive. With this design approach all the related data is also grouped together into self-
    contained components. Thus, the components are cohesive.
The two design approaches differ in a couple of important ways:
• The Russian Doll design facilitates hiding (localizing) namespace complexities. The Salami
  Slice design does not.
• The Salami Slice design facilitates component reuse. The Russian Doll design does not.
Is there a design which facilitates hiding (localizing) namespace complexities, and facilitates
component reuse? Yes there is!

Consider the Book example again. An alternative design is to create a global type definition
which nests the Title and Author element declarations within it:

               <xsd:complexType name=“Publication”>
                 <xsd:sequence>
                   <xsd:element name=“Title” type=“xsd:string”/>
                   <xsd:element name=“Author” type=“xsd:string”/>
                 </xsd:sequence>
               </xsd:complexType>
               <xsd:element name=“Book” type=“Publication”/>

This design has both benefits:
• it is capable of hiding (localizing) the namespace complexity of Title and Author, and
• it has a reusable Publication type component.




                                             24
Venetian Blind Design
With this design approach we disassemble the problem into individual components, as the Salami
Slice design does, but instead of creating element declarations, we create type definitions. Here’s
what our example looks like with this design approach:

               <xsd:simpleType name=“Title”>
                 <xsd:restriction base=“xsd:string”>
                   <xsd:enumeration value=“Mr.”/>
                   <xsd:enumeration value=“Mrs.”/>
                   <xsd:enumeration value=“Dr.”/>
                 </xsd:restriction>
               </xsd:simpleType>
               <xsd:simpleType name=“Name”>
                 <xsd:restriction base=“xsd:string”>
                   <xsd:minLength value=“1”/>
                 </xsd:restriction>
               </xsd:simpleType>
               <xsd:complexType name=“Publication”>
                 <xsd:sequence>
                   <xsd:element name=“Title” type=“Title”/>
                   <xsd:element name=“Author” type=“Name”/>
                 </xsd:sequence>
               </xsd:complexType>
               <xsd:element name=“Book” type=“Publication”/>

This design has:
• maximized reuse (there are four reusable components - the Title type, the Name type, the
  Publication type, and the Book element)
• maximized the potential to hide (localize) namespaces [note how this has been phrased:
  “maximized the potential ...“Whether, in fact, the namespaces of Title and Author are hidden
  or exposed, is determined by the elementFormDefault “switchquot;].
The Venetian Blind design espouses these guidelines ...
• Design your schema to maximize the potential for hiding (localizing) namespace complexities.
• Use elementFormDefault to act as a switch for controlling namespace exposure - if you want
  element namespaces exposed in instance documents, simply turn the elementFormDefault
  switch to “onquot; (i.e, set elementFormDefault= “qualifiedquot;); if you don’t want element
  namespaces exposed in instance documents, simply turn the elementFormDefault switch to
  “offquot; (i.e., set elementFormDefault=“unqualifiedquot;).
• Design your schema to maximize reuse.
• Use type definitions as the main form of component reuse.
• Nest element declarations within type definitions.
Let’s compare the Venetian Blind design with the Salami Slice design. Recall our example:




                                                 25
Salami Slice Design:
               <xsd:element name=“Titlequot; type=“xsd:stringquot;/>
               <xsd:element name=“Authorquot; type=“xsd:stringquot;/>
               <xsd:element name=“Bookquot;>
                 <xsd:complexType>
                   <xsd:sequence>
                     <xsd:element ref=“Titlequot;/>
                     <xsd:element ref=“Authorquot; />
                   </xsd:sequence>
                 </xsd:complexType>
               </xsd:element>

The Salami Slice design also results in creating reusable (element) components, but it has
absolutely no potential for namespace hiding.

“Howeverquot;, you argue, “Suppose that I want namespaces exposed in instance documents. [We
have seen cases where this is desired.] So the Salami Slice design is a good approach for me.
Right?quot;

Let’s think about this for a moment. What if at a later date you change your mind and wish to
hide namespaces (what if your users hate seeing all those namespace qualifiers in instance
documents)? You will need to redesign your schema (possibly scraping it and starting over).

Better to adopt the Venetian Blind Design, which allows you to control whether namespaces are
hidden or exposed by simply setting the value of elementFormDefault. No redesign of your
schema is needed as you switch from exposing to hiding, or vice versa.

[That said ... your particular project may need to sacrifice the ability to turn on/off namespace
exposure because you require instance documents to be able to use element substitution. In such
circumstances the Salami Slice design approach is the only viable alternative.]

Here are the characteristics of the Venetian Blind Design.

Venetian Blind Design Characteristics:
[1] Maximum reuse. The primary component of reuse are type definitions.
[2] Maximum namespace hiding. Element declarations are nested within types, thus maximizing
    the potential for namespace hiding.
[3] Easy exposure switching. Whether namespaces are hidden (localized) in the schema or
    exposed in instance documents is controlled by the elementFormDefault switch.
[4] Coupled. This design generates a set of components which are interconnected (i.e.,
    dependent).
[5] Cohesive. As with the other designs, the components group together related data. Thus, the
    components are cohesive.




                                             26
Best Practice
[1] The Venetian Blind design is the one to choose where your schemas require the flexibility to
    turn namespace exposure on or off with a simple switch, and where component reuse is
    important.
[2] Where your task requires that you make available to instance document authors the option
    to use element substitution, then use the Salami Slice design.
[3] Where mimimizing size and coupling of components is of utmost concern then use the
    Russian Doll design.




                                                27

Más contenido relacionado

La actualidad más candente

Week 12 xml and xsl
Week 12 xml and xslWeek 12 xml and xsl
Week 12 xml and xslhapy
 
Unit ii java script and xhtml documents and dynamic documents with javascript
Unit ii java script and xhtml documents and dynamic documents with javascriptUnit ii java script and xhtml documents and dynamic documents with javascript
Unit ii java script and xhtml documents and dynamic documents with javascriptzahid7578
 
CSC103 Web Technologies: HTML, CSS, JS
CSC103 Web Technologies: HTML, CSS, JSCSC103 Web Technologies: HTML, CSS, JS
CSC103 Web Technologies: HTML, CSS, JSRichard Homa
 
Introduction to HTML, CSS, and Javascript
Introduction to HTML, CSS, and JavascriptIntroduction to HTML, CSS, and Javascript
Introduction to HTML, CSS, and JavascriptAgustinus Theodorus
 
Displaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSLDisplaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSLBình Trọng Án
 
JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulationborkweb
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS MethodologyZohar Arad
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in androidMahmudul Hasan
 
Everything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskEverything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskRichard Davis
 
KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7phuphax
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2borkweb
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningRasan Samarasinghe
 
A quick guide to Css and java script
A quick guide to Css and  java scriptA quick guide to Css and  java script
A quick guide to Css and java scriptAVINASH KUMAR
 

La actualidad más candente (20)

Week 12 xml and xsl
Week 12 xml and xslWeek 12 xml and xsl
Week 12 xml and xsl
 
Unit ii java script and xhtml documents and dynamic documents with javascript
Unit ii java script and xhtml documents and dynamic documents with javascriptUnit ii java script and xhtml documents and dynamic documents with javascript
Unit ii java script and xhtml documents and dynamic documents with javascript
 
DTD
DTDDTD
DTD
 
Html (1)
Html (1)Html (1)
Html (1)
 
CSC103 Web Technologies: HTML, CSS, JS
CSC103 Web Technologies: HTML, CSS, JSCSC103 Web Technologies: HTML, CSS, JS
CSC103 Web Technologies: HTML, CSS, JS
 
Introduction to HTML, CSS, and Javascript
Introduction to HTML, CSS, and JavascriptIntroduction to HTML, CSS, and Javascript
Introduction to HTML, CSS, and Javascript
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
Displaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSLDisplaying XML Documents Using CSS and XSL
Displaying XML Documents Using CSS and XSL
 
What is xml
What is xmlWhat is xml
What is xml
 
JavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM ManipulationJavaScript: Ajax & DOM Manipulation
JavaScript: Ajax & DOM Manipulation
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
HTML5 Semantics
HTML5 SemanticsHTML5 Semantics
HTML5 Semantics
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
Everything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskEverything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To Ask
 
KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7KMUTNB - Internet Programming 4/7
KMUTNB - Internet Programming 4/7
 
Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2Javascript: Ajax & DOM Manipulation v1.2
Javascript: Ajax & DOM Manipulation v1.2
 
Xml
XmlXml
Xml
 
DIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web DesigningDIWE - Coding HTML for Basic Web Designing
DIWE - Coding HTML for Basic Web Designing
 
Sgml
SgmlSgml
Sgml
 
A quick guide to Css and java script
A quick guide to Css and  java scriptA quick guide to Css and  java script
A quick guide to Css and java script
 

Similar a Global Versus Local (20)

Zero One Or Many Namespaces
Zero One Or Many NamespacesZero One Or Many Namespaces
Zero One Or Many Namespaces
 
Default Namespace
Default NamespaceDefault Namespace
Default Namespace
 
Extensible Content Models
Extensible Content ModelsExtensible Content Models
Extensible Content Models
 
Xml For Dummies Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
Xml For Dummies   Chapter 10 Building A Custom Xml Schema it-slideshares.blog...Xml For Dummies   Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
Xml For Dummies Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
 
Xsd
XsdXsd
Xsd
 
Xsd
XsdXsd
Xsd
 
XML
XMLXML
XML
 
Best Practice In Nutshell
Best Practice In NutshellBest Practice In Nutshell
Best Practice In Nutshell
 
O9schema
O9schemaO9schema
O9schema
 
Schema
SchemaSchema
Schema
 
Variable Content Containers
Variable Content ContainersVariable Content Containers
Variable Content Containers
 
XML
XMLXML
XML
 
Xml part4
Xml part4Xml part4
Xml part4
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
Xml Schema
Xml SchemaXml Schema
Xml Schema
 
Web Designing
Web DesigningWeb Designing
Web Designing
 
Hide Versus Expose
Hide Versus ExposeHide Versus Expose
Hide Versus Expose
 
Xml processing in scala
Xml processing in scalaXml processing in scala
Xml processing in scala
 
Xml processing in scala
Xml processing in scalaXml processing in scala
Xml processing in scala
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise Monitor
 

Más de LiquidHub

Share point 2013 coding standards and best practices 1.0
Share point 2013 coding standards and best practices 1.0Share point 2013 coding standards and best practices 1.0
Share point 2013 coding standards and best practices 1.0LiquidHub
 
Sharepoint 2013 upgrade process
Sharepoint 2013 upgrade processSharepoint 2013 upgrade process
Sharepoint 2013 upgrade processLiquidHub
 
Share point 2013
Share point 2013Share point 2013
Share point 2013LiquidHub
 
Share point 2010-uiimprovements
Share point 2010-uiimprovementsShare point 2010-uiimprovements
Share point 2010-uiimprovementsLiquidHub
 
Microsoft office-sharepoint-server-2007-presentation-120211522467022-2
Microsoft office-sharepoint-server-2007-presentation-120211522467022-2Microsoft office-sharepoint-server-2007-presentation-120211522467022-2
Microsoft office-sharepoint-server-2007-presentation-120211522467022-2LiquidHub
 
Managing metadata in_share_point_2010
Managing metadata in_share_point_2010Managing metadata in_share_point_2010
Managing metadata in_share_point_2010LiquidHub
 
Fast search for share point
Fast search for share pointFast search for share point
Fast search for share pointLiquidHub
 
Simple Farm Server Deployment
Simple Farm Server DeploymentSimple Farm Server Deployment
Simple Farm Server DeploymentLiquidHub
 
Pre Install Databases
Pre Install DatabasesPre Install Databases
Pre Install DatabasesLiquidHub
 
Moss 2007 Deployment Detail
Moss 2007 Deployment DetailMoss 2007 Deployment Detail
Moss 2007 Deployment DetailLiquidHub
 
Moss 2007 Backup Strategies
Moss 2007 Backup StrategiesMoss 2007 Backup Strategies
Moss 2007 Backup StrategiesLiquidHub
 
How To Configure Email Enabled Lists In Moss2007 Rtm Using Exchange 2003
How To Configure Email Enabled Lists In Moss2007 Rtm Using Exchange 2003How To Configure Email Enabled Lists In Moss2007 Rtm Using Exchange 2003
How To Configure Email Enabled Lists In Moss2007 Rtm Using Exchange 2003LiquidHub
 
5060 A 01 Demonstration Steps
5060 A 01 Demonstration Steps5060 A 01 Demonstration Steps
5060 A 01 Demonstration StepsLiquidHub
 
Working With Infopath 2007
Working With Infopath 2007Working With Infopath 2007
Working With Infopath 2007LiquidHub
 
Whats New In Microsoft Windows Share Point Services Feature Walkthrough
Whats New In Microsoft Windows Share Point Services Feature WalkthroughWhats New In Microsoft Windows Share Point Services Feature Walkthrough
Whats New In Microsoft Windows Share Point Services Feature WalkthroughLiquidHub
 
Overviewofthe2007 Microsoft Office System Components Refresh
Overviewofthe2007 Microsoft Office System Components RefreshOverviewofthe2007 Microsoft Office System Components Refresh
Overviewofthe2007 Microsoft Office System Components RefreshLiquidHub
 
Organizingand Finding Resourceswith Office Share Point Server2007 Refresh
Organizingand Finding Resourceswith Office Share Point Server2007 RefreshOrganizingand Finding Resourceswith Office Share Point Server2007 Refresh
Organizingand Finding Resourceswith Office Share Point Server2007 RefreshLiquidHub
 

Más de LiquidHub (20)

Share point 2013 coding standards and best practices 1.0
Share point 2013 coding standards and best practices 1.0Share point 2013 coding standards and best practices 1.0
Share point 2013 coding standards and best practices 1.0
 
Sharepoint 2013 upgrade process
Sharepoint 2013 upgrade processSharepoint 2013 upgrade process
Sharepoint 2013 upgrade process
 
Share point 2013
Share point 2013Share point 2013
Share point 2013
 
Share point 2010-uiimprovements
Share point 2010-uiimprovementsShare point 2010-uiimprovements
Share point 2010-uiimprovements
 
Microsoft office-sharepoint-server-2007-presentation-120211522467022-2
Microsoft office-sharepoint-server-2007-presentation-120211522467022-2Microsoft office-sharepoint-server-2007-presentation-120211522467022-2
Microsoft office-sharepoint-server-2007-presentation-120211522467022-2
 
Managing metadata in_share_point_2010
Managing metadata in_share_point_2010Managing metadata in_share_point_2010
Managing metadata in_share_point_2010
 
Fast search for share point
Fast search for share pointFast search for share point
Fast search for share point
 
Simple Farm Server Deployment
Simple Farm Server DeploymentSimple Farm Server Deployment
Simple Farm Server Deployment
 
Pre Install Databases
Pre Install DatabasesPre Install Databases
Pre Install Databases
 
Moss 2007 Deployment Detail
Moss 2007 Deployment DetailMoss 2007 Deployment Detail
Moss 2007 Deployment Detail
 
Moss 2007 Backup Strategies
Moss 2007 Backup StrategiesMoss 2007 Backup Strategies
Moss 2007 Backup Strategies
 
How To Configure Email Enabled Lists In Moss2007 Rtm Using Exchange 2003
How To Configure Email Enabled Lists In Moss2007 Rtm Using Exchange 2003How To Configure Email Enabled Lists In Moss2007 Rtm Using Exchange 2003
How To Configure Email Enabled Lists In Moss2007 Rtm Using Exchange 2003
 
Bdc Screens
Bdc ScreensBdc Screens
Bdc Screens
 
Bdc Screens
Bdc ScreensBdc Screens
Bdc Screens
 
5060 A 01 Demonstration Steps
5060 A 01 Demonstration Steps5060 A 01 Demonstration Steps
5060 A 01 Demonstration Steps
 
5060 A 01
5060 A 015060 A 01
5060 A 01
 
Working With Infopath 2007
Working With Infopath 2007Working With Infopath 2007
Working With Infopath 2007
 
Whats New In Microsoft Windows Share Point Services Feature Walkthrough
Whats New In Microsoft Windows Share Point Services Feature WalkthroughWhats New In Microsoft Windows Share Point Services Feature Walkthrough
Whats New In Microsoft Windows Share Point Services Feature Walkthrough
 
Overviewofthe2007 Microsoft Office System Components Refresh
Overviewofthe2007 Microsoft Office System Components RefreshOverviewofthe2007 Microsoft Office System Components Refresh
Overviewofthe2007 Microsoft Office System Components Refresh
 
Organizingand Finding Resourceswith Office Share Point Server2007 Refresh
Organizingand Finding Resourceswith Office Share Point Server2007 RefreshOrganizingand Finding Resourceswith Office Share Point Server2007 Refresh
Organizingand Finding Resourceswith Office Share Point Server2007 Refresh
 

Último

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 

Último (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 

Global Versus Local

  • 1. Global versus Local Table of Contents Issue Introduction Russian Doll Design Salami Slice Design Russian Doll Design Characteristics Salami Slice Design Characteristics Venetian Blind Design Venetian Blind Design Characteristics Best Practice Issue When should an element or type be declared global versus when should it be declared local? Introduction [Recall that a component (element, complexType, or simpleType) is “global” if it is an immediate child of <schema>, whereas it is “local” if it is not an immediate child of <schema>, i.e., it is nested within another component.] What advice would you give to someone who was to ask you, “In general, when should an element (or type) be declared global versus when should it be declared local”? The purpose of this chapter is to provide answers to that question. Below is a snippet of an XML instance document. We will explore the different design strategies using this example. <Book> <Title>Illusions</Title> <Author>Richard Bach</Author> </Book> Russian Doll Design This design approach has the schema structure mirror the instance document structure, e.g., declare a Book element and within it declare a Title element followed by an Author element: <xsd:element name=“Book”> <xsd:complexType> <xsd:sequence> <xsd:element name=“Title” type=“xsd:string”/> <xsd:element name=“Author” type=“xsd:string”/> </xsd:sequence> </xsd:complexType> </element> 22
  • 2. The instance document has all its components bundled together. Likewise, the schema is designed to bundle together all its element declarations. This design represents one end of the design spectrum. Salami Slice Design The Salami Slice design represents the other end of the design spectrum. With this design we disassemble the instance document into its individual components. In the schema we define each component (as an element declaration), and then assemble them together: <xsd:element name=“Title” type=“xsd:string”/> <xsd:element name=“Author” type=“xsd:string”/> <xsd:element name=“Book”> <xsd:complexType> <xsd:sequence> <xsd:element ref=“Title”/> <xsd:element ref=“Author”/> </xsd:sequence> </xsd:complexType> </xsd:element> Note how the schema declared each component individually (Title, and Author) and then assembled them together (by ref’ing them) in the creation of the Book component. These two designs represent opposite ends of the design spectrum. To understand these designs it may help to think in terms of boxes, where a box represents an element or type: • The Russian Doll design corresponds to having a single box, and it has nested within it boxes, which in turn have boxes nested within them, and so on. (boxes within boxes, just like a Russian Doll!) • The Salami Slice design corresponds to having many separate boxes which are assembled together (separate boxes combined together, just like Salami slices brought together in a sandwich!) Let’s examine the characteristics of each of the two designs. (In so doing it will yield insights into another design.) Russian Doll Design Characteristics [1] Opaque content. The content of Book is opaque to other schemas, and to other parts of the same schema. The impact of this is that none of the types or elements within Book are reusable. [2] Localized scope. The region of the schema where the Title and Author element declarations are applicable is localized to within the Book element. The impact of this is that if the schema has set elementFormDefault=“unqualified” then the namespaces of Title and Author are hidden (localized) within the schema. 23
  • 3. [3] Compact. Everything is bundled together into a tidy, single unit. [4] Decoupled. With this design approach each component is self-contained (i.e., they don’t interact with other components). Consequently, changes to the components will have limited impact. For example, if the components within Book changes it will have a limited impact since they are not coupled to components outside of Book. [5] Cohesive. With this design approach all the related data is grouped together into self- contained components, i.e., the components are cohesive. Salami Slice Design Characteristics [1] Transparent content. The components which make up Book are visible to other schemas, and to other parts of the same schema. The impact of this is that the types and elements within Book are reusable. [2] Global scope. All components have global scope. The impact of this is that, irrespective of the value of elementFormDefault, the namespaces of Title and Author will be exposed in instance documents. [3] Verbose. Everything is laid out and clearly visible. [4] Coupled. In our example we saw that the Book element depends on the Title and Author elements. If those elements were to change it would impact the Book element. Thus, this design produces a set of interconnected (coupled) components. [5] Cohesive. With this design approach all the related data is also grouped together into self- contained components. Thus, the components are cohesive. The two design approaches differ in a couple of important ways: • The Russian Doll design facilitates hiding (localizing) namespace complexities. The Salami Slice design does not. • The Salami Slice design facilitates component reuse. The Russian Doll design does not. Is there a design which facilitates hiding (localizing) namespace complexities, and facilitates component reuse? Yes there is! Consider the Book example again. An alternative design is to create a global type definition which nests the Title and Author element declarations within it: <xsd:complexType name=“Publication”> <xsd:sequence> <xsd:element name=“Title” type=“xsd:string”/> <xsd:element name=“Author” type=“xsd:string”/> </xsd:sequence> </xsd:complexType> <xsd:element name=“Book” type=“Publication”/> This design has both benefits: • it is capable of hiding (localizing) the namespace complexity of Title and Author, and • it has a reusable Publication type component. 24
  • 4. Venetian Blind Design With this design approach we disassemble the problem into individual components, as the Salami Slice design does, but instead of creating element declarations, we create type definitions. Here’s what our example looks like with this design approach: <xsd:simpleType name=“Title”> <xsd:restriction base=“xsd:string”> <xsd:enumeration value=“Mr.”/> <xsd:enumeration value=“Mrs.”/> <xsd:enumeration value=“Dr.”/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name=“Name”> <xsd:restriction base=“xsd:string”> <xsd:minLength value=“1”/> </xsd:restriction> </xsd:simpleType> <xsd:complexType name=“Publication”> <xsd:sequence> <xsd:element name=“Title” type=“Title”/> <xsd:element name=“Author” type=“Name”/> </xsd:sequence> </xsd:complexType> <xsd:element name=“Book” type=“Publication”/> This design has: • maximized reuse (there are four reusable components - the Title type, the Name type, the Publication type, and the Book element) • maximized the potential to hide (localize) namespaces [note how this has been phrased: “maximized the potential ...“Whether, in fact, the namespaces of Title and Author are hidden or exposed, is determined by the elementFormDefault “switchquot;]. The Venetian Blind design espouses these guidelines ... • Design your schema to maximize the potential for hiding (localizing) namespace complexities. • Use elementFormDefault to act as a switch for controlling namespace exposure - if you want element namespaces exposed in instance documents, simply turn the elementFormDefault switch to “onquot; (i.e, set elementFormDefault= “qualifiedquot;); if you don’t want element namespaces exposed in instance documents, simply turn the elementFormDefault switch to “offquot; (i.e., set elementFormDefault=“unqualifiedquot;). • Design your schema to maximize reuse. • Use type definitions as the main form of component reuse. • Nest element declarations within type definitions. Let’s compare the Venetian Blind design with the Salami Slice design. Recall our example: 25
  • 5. Salami Slice Design: <xsd:element name=“Titlequot; type=“xsd:stringquot;/> <xsd:element name=“Authorquot; type=“xsd:stringquot;/> <xsd:element name=“Bookquot;> <xsd:complexType> <xsd:sequence> <xsd:element ref=“Titlequot;/> <xsd:element ref=“Authorquot; /> </xsd:sequence> </xsd:complexType> </xsd:element> The Salami Slice design also results in creating reusable (element) components, but it has absolutely no potential for namespace hiding. “Howeverquot;, you argue, “Suppose that I want namespaces exposed in instance documents. [We have seen cases where this is desired.] So the Salami Slice design is a good approach for me. Right?quot; Let’s think about this for a moment. What if at a later date you change your mind and wish to hide namespaces (what if your users hate seeing all those namespace qualifiers in instance documents)? You will need to redesign your schema (possibly scraping it and starting over). Better to adopt the Venetian Blind Design, which allows you to control whether namespaces are hidden or exposed by simply setting the value of elementFormDefault. No redesign of your schema is needed as you switch from exposing to hiding, or vice versa. [That said ... your particular project may need to sacrifice the ability to turn on/off namespace exposure because you require instance documents to be able to use element substitution. In such circumstances the Salami Slice design approach is the only viable alternative.] Here are the characteristics of the Venetian Blind Design. Venetian Blind Design Characteristics: [1] Maximum reuse. The primary component of reuse are type definitions. [2] Maximum namespace hiding. Element declarations are nested within types, thus maximizing the potential for namespace hiding. [3] Easy exposure switching. Whether namespaces are hidden (localized) in the schema or exposed in instance documents is controlled by the elementFormDefault switch. [4] Coupled. This design generates a set of components which are interconnected (i.e., dependent). [5] Cohesive. As with the other designs, the components group together related data. Thus, the components are cohesive. 26
  • 6. Best Practice [1] The Venetian Blind design is the one to choose where your schemas require the flexibility to turn namespace exposure on or off with a simple switch, and where component reuse is important. [2] Where your task requires that you make available to instance document authors the option to use element substitution, then use the Salami Slice design. [3] Where mimimizing size and coupling of components is of utmost concern then use the Russian Doll design. 27