SlideShare a Scribd company logo
1 of 10
Download to read offline
Hide (Localize) Namespaces
                               Versus
                        Expose Namespaces
Table of Contents
               Issue
               Introduction
               Example
               Technical Requirements for Hiding (Localizing) Namespaces
               Best Practice

Issue

When should a schema be designed to hide (localize) within the schema the namespaces of the
elements and attributes it is using, versus when should it be designed to expose the namespaces
in instance documents?
Introduction

A typical schema will reuse elements and types from multiple schemas, each with different
namespaces.


          <xsd:schema …                              <xsd:schema …
             targetNamespace=“A”>                       targetNamespace=“B”>

                   A.xsd                                       B.xsd

                    <xsd:schema …
                              targetNamespace=quot;Cquot;>
                        <xsd:import namespace=quot;Aquot;
                                    schemaLocation=quot;A.xsdquot;/>
                        <xsd:import namespace=quot;Bquot;
                                    schemaLocation=quot;B.xsdquot;/>
                        …
                    </xsd:schema>
                                            C.xsd




                                               12
A schema, then, may be comprised of components from multiple namespaces. Thus, when a
schema is designed the schema designer must decide whether or not the origin (namespace) of
each element should be exposed in the instance documents.


                                   Instance Document

                    <myDoc …
                       schemaLocation=“C C.xsd”>




                    </myDoc>
                          The namespaces of the components are not
                              visible in the instance documents.




                                    Instance Document

                    <myDoc …
                       schemaLocation=“C C.xsd”>




                    </myDoc>
                      The namespaces of the components are visible
                              in the instance documents.



                                             13
A binary switch attribute in the schema is used to control the hiding/exposure of namespaces: by
setting elementFormDefault=“unqualified” the namespaces will be hidden (localized) within the
schema, and by setting elementFormDefault=“qualified” the namespaces will be exposed in
instance documents.


                          elementFormDefault - the
                             Exposure “Switch”
                                                         Schema
                         hide
                      expose

                                           elementFormDefault




              <xsd:schema …                               <xsd:schema …
                                                    vs
                  elementFormDefault=“qualified”>             elementFormDefault=“unqualified”>




Example:


       Nikon.xsd                                                             Pentax.xsd
                                    Olympus.xsd




                                      Camera.xsd


Below is a schema for describing a camera. The camera schema reuses components from other
schemas - the camera’s <body> element reuses a type from the Nikon schema, the camera’s
<lens> element reuses a type from the Olympus schema, and the camera’s <manual_adaptor>
element reuses a type from the Pentax schema.




                                                         14
Camera.xsd



    <?xml version=quot;1.0quot;?>
    <xsd:schema xmlns:xsd=quot;http://www.w3.org/2001/XMLSchemaquot;
                targetNamespace=quot;http://www.camera.orgquot;
                xmlns:nikon=quot;http://www.nikon.comquot;
                xmlns:olympus=quot;http://www.olympus.comquot;
                xmlns:pentax=quot;http://www.pentax.comquot;
                elementFormDefault=quot;unqualifiedquot;>
        <xsd:import namespace=quot;http://www.nikon.comquot;
                     schemaLocation=quot;Nikon.xsdquot;/>
        <xsd:import namespace=quot;http://www.olympus.comquot;
                     schemaLocation=quot;Olympus.xsdquot;/>
        <xsd:import namespace=quot;http://www.pentax.comquot;
                     schemaLocation=quot;Pentax.xsdquot;/>
        <xsd:element name=quot;cameraquot;>
            <xsd:complexType>
                  <xsd:sequence>
                      <xsd:element name=quot;bodyquot; type=quot;nikon:body_typequot;/>
                      <xsd:element name=quot;lensquot; type=quot;olympus:lens_typequot;/>
                      <xsd:element name=quot;manual_adapterquot;
                                   type=quot;pentax:manual_adapter_typequot;/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
    </xsd:schema>

             This schema is designed to hide namespaces


Note the three <import> elements for importing the Nikon, Olympus, and Pentax components.
Also note that the <schema> attribute, elementFormDefault has been set to the value of
unqualified. This is a critical attribute. Its value controls whether the namespaces of the elements
being used by the schema will be hidden or exposed in instance documents (thus, it behaves like
a switch turning namespace exposure on/off). Because it has been set to “unqualified” in this
schema, the namespaces will be remain hidden (localized) within the schema, and will not be
visible in instance documents, as we see here:




                                                 15
Camera.xml (namespaces hidden)



                                    Instance Document
   <?xml version=quot;1.0quot;?>
   <my:camera xmlns:my=quot;http://www.camera.orgquot;
              xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot;
              xsi:schemaLocation=
                      quot;http://www.camera.org
                       Camera.xsdquot;>
      <body>
       <body>
                    Instance document with namespaces hidden
         <description>Ergonomically designed casing for easy handling</description>
           <description>Ergonomically designed casing for easy handling</descriptio
      </body>
       </body>
                    (localized) within the schema
      <lens>
       <lens>
          <zoom>300mm</zoom>
           <zoom>300mm</zoom>
          <f-stop>1.2</f-stop>
           <f-stop>1.2</f-stop>
      </lens>
       </lens>
      <manual_adapter>
       <manual_adapter>
          <speed>1/10,000 sec to 100 sec</speed>
           <speed>1/10,000 sec to 100 sec</speed>
      </manual_adapter>
       </manual_adapter>
   </my:camera>

     Instance document with namespaces hidden (localized) in the schema.
     --> The fact that the <description> element comes from the Nikon schema,
     the <zoom> and <f-stop> elements come from the Olympus schema, and the
     <speed> element comes from the Pentax schema is totally transparent to the
     instance document.


The only namespace qualifier exposed in the instance document is on the <camera> root
element. The rest of the document is completely free of namespace qualifiers. The Nikon,
Olympus, and Pentax namespaces are completely hidden (localized) within the schema!

Looking at the instance document one would never realize that the schema got its components
from three other schemas. Such complexities are localized to the schema. Thus, we say that the
schema has been designed in such a fashion that its component namespace complexities are
“hidden” from the instance document.

On the other hand, if the above schema had set elementFormDefault=“qualified” then the
namespace of each element would be exposed in instance documents. Here’s what the instance
document would look like:




                                               16
Camera.xml (namespaces exposed)



                                Instance Document
         <?xml version=quot;1.0quot;?>
         <c:camera xmlns:c=quot;http://www.camera.orgquot;
                   xmlns:nikon=quot;http://www.nikon.comquot;
                   xmlns:olympus=quot;http://www.olympus.comquot;
                   xmlns:pentax=quot;http://www.pentax.comquot;
                   xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot;
                   xsi:schemaLocation=
                            quot;http://www.camera.org
                             Camera.xsd>
             <c:body>
                 <nikon:description>Ergonomically designed casing for easy
                                            handling</nikon:description>
                                    handling</nikon:description>
             </c:body>
             <c:lens>
                 <olympus:zoom>300mm</olympus:zoom>
                 <olympus:zoom>300mm</olympus:zoom>
                 <olympus:f-stop>1.2</olympus:f-stop>
                 <olympus:f-stop>1.2</olympus:f-stop>
             </c:lens>
             <c:manual_adapter>
                 <pentax:speed>1/10,000 sec to 100 sec</pentax:speed>
                  <pentax:speed>1/10,000 sec to 100 sec</pentax:speed>
             </c:manual_adapter>
         </c:camera>

                       Instance document with namespaces exposed


Note that each element is explicitly namespace-qualified. Also, observe the declaration for each
namespace. Due to the way the schema has been designed, the complexities of where the schema
obtained its components have been “pushed out” to the instance document. Thus, the reader of
this instance document is “exposed” to the fact that the schema obtained the description element
from the Nikon schema, the zoom and f-stop elements from the Olympus schemas, and the speed
element from the Pentax schema.
All Schemas must have a Consistent Value for elementFormDefault!

Be sure to note that elementFormDefault applies just to the schema that it is in. It does not
apply to schemas that it includes or imports. Consequently, if you want to hide namespaces then
all schemas involved must have set elementFormDefault=“unqualified”. Likewise, if you want to
expose namespaces then all schemas involved must have set elementFormDefault=“qualified”.
To see what happens when you “mix” elementFormDefault values, let’s suppose that Camera.xsd
and Olympus.xsd have both set in their schema elementFormDefault=“unqualified”, whereas
Nikon.xsd and Pentax.xsd have both set elementFormDefault=“qualified”.




                                               17
element FormDefault= quot;unqualifiedquot;



                                                 Olympus.xsd


                                                                      elementFormDefault= quot;qualifiedquot;
               element FormDefault=quot;qualifiedquot;


                                                                              Pentax.xsd
                    Nikon.xsd




                                         elementFormDefault= quot;unqualified quot;




                                                 Camera.xsd


Here’s what an instance document looks like with this “mixed” design:
Camera.xml (mixed design)



                                           Instance Document
               <?xml version=quot;1.0quot;?>
               <my:camera xmlns:my=quot;http://www.camera.orgquot;
                           xmlns:nikon=quot;http://www.nikon.comquot;
                           xmlns:pentax=quot;http://www.pentax.comquot;
                           xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot;
                           xsi:schemaLocation=
                                   quot;http://www.camera.org
                                    Camera.xsd>
                  <body>
                   <body>
                              Instance document with namespaces hidden
                     <description>Ergonomically designed designed casing for easy
                     <nikon:description>Ergonomically designed casing for easy
                       <nikon:description>Ergonomically casing for easy
                                           handling</description>
                                                 handling</nikon:description>
                                           handling</nikon:description>
                              (localized) within the schema
                  </body>
                   </body>
                  <lens>
                   <lens>
                      <zoom>300mm</zoom>
                       <olympus:zoom>300mm</olympus:zoom>
                        <olympus:zoom>300mm</olympus:zoom>
                      <f-stop>1.2</f-stop>
                       <olympus:f-stop>1.2</olympus:f-stop>
                                <olympus:f-stop>1.2</olympus:f-stop>
                  </lens>
                   </lens>
                  <manual_adapter>
                   <manual_adapter>
                      <speed>1/10,000 sec to 100 sec</speed>
                      <pentax:speed>1/10,000 sec to 100 sec</pentax:speed>
                       <pentax:speed>1/10,000 sec to 100 sec</pentax:speed>
                  </manual_adapter>
                   </manual_adapter>
               </my:camera>


              Hiding/exposure mix: This instance document has the Nikon and
              Pentax namespaces exposed, while the Camera and Olympus
              namespaces are hidden.




                                                        18
Observe that in this instance document some of the elements are namespace-qualified, while
others are not. Namely, those elements from the Camera and Olympus schemas are not qualified,
whereas the elements from the Nikon and Pentax schemas are qualified.
Technical Requirements for Hiding (Localizing) Namespaces

There are two requirements on an element for its namespace to be hidden from instance
documents:
[1] The value of elementFormDefault must be “unqualified”.
[2] The element must not be globally declared. For example:
            <?xml version=“1.0”?>
            <xsd:schema ...>
              <xsd:element name=“foo”>
              ...
            </xsd:schema ...>

The element foo can never have its namespace hidden from instance documents, regardless of the
value of elementFormDefault. foo is a global element (i.e., an immediate child of <schema>) and
therefore must always be qualified. To enable namespace hiding the element must be a local
element.
Best Practice

For this issue there is no definitive Best Practice with respect to whether to design your schemas
to hide/localize namespaces, or design it to expose namespaces. Sometimes it’s best to hide the
namespaces. Othertimes it’s best to expose the namespaces. Both have their pluses and minus, as
is discussed below.

However, there are Best Practices with regards to other aspects of this issue. They are:
1.   Whenever you create a schema, make two copies of it. The copies should be identical,
     except that in one copy set elementFormDefault=“qualified”, whereas in the other copy set
     elementFormDefault=“unqualified”. If you make two versions of all your schemas then
     people who use your schemas will be able to implement either design approach - hide
     (localize) namespaces, or expose namespaces.
2. Minimize the use of global elements and attributes so that elementFormDefault can behave
   as an “exposure switch”. The rationale for this was described above, in Technical
   Requirements for Hiding (Localizing) Namespaces
Advantages of Hiding (Localizing) Component Namespaces within the Schema

The instance document is simple. It’s easy to read and understand. There are no namespace
qualifiers cluttering up the document, except for the one on the document element (which is okay
because it shows the domain of the document). The knowledge of where the schema got its
components is irrelevant and localized to the schema.




                                                19
Design your schema to hide (localize) namespaces within the schema ...
– when simplicity, readability, and understandability of instance documents is of utmost
  importance when namespaces in the instance document provide no necessary additional
  information. In many scenarios the users of the instance documents are not XML-experts.
  Namespaces would distract and confuse such users, where they are just concerned about
  structure and content.
– when you need the flexibility of being able to change the schema without impact to instance
  documents. To see this, imagine that when a schema is originally designed it imports elements/
  types from another namespace. Since the schema has been designed to hide (localize) the
  namespaces, instance documents do not see the namespaces of the imported elements. Then,
  imagine that at a later date the schema is changed such that instead of importing the elements/
  types, those elements and types are declared/defined right within the schema (inline). This
  change from using elements/types from another namespace to using elements/types in the local
  namespace has no impact to instance documents because the schema has been designed to
  shield instance documents from where the components come from.
Advantages of Exposing Namespaces in Instance Documents

If your company spends the time and money to create a reusable schema component, and makes
it available to the marketplace, then you will most likely want recognition for that component.
Namespaces provide a means to achieve recognition. For example,
            <nikon:description>
                Ergonomically designed casing for easy handling</
            nikon:description>


There can be no misunderstanding that this component comes from Nikon. The namespace
qualifier is providing information on the origin/lineage of the description element.

Another case where it is desirable to expose namespaces is when processing instance documents.
Oftentimes when processing instance documents the namespace is required to determine how an
element is to be processed (e.g., “if the element comes from this namespace then we’ll process it
in this fashion, if it comes from this other namespace then we’ll process it in a different
fashion”). If the namespaces are hidden then your application is forced to do a lookup in the
schema for every element. This will be unacceptably slow.

Design your schema to expose namespaces in instance documents ...
– when lineage/ownership of the elements are important to the instance document users (such as
  for copyright purposes).
– when there are multiple elements with the same name but different semantics then you may
  want to namespace-qualify them so that they can be differentiated (e.g, publisher:body versus
  human:body). [In some cases you have multiple elements with the same name and different
  semantics but the context of the element is sufficient to determine its semantics. Example: the
  title element in <person><title> is easily distinguished from the title element in
  <chapter><title>. In such cases there is less justification for designing your schema to expose
  the namespaces.]

                                                20
– when processing (by an application) of the instance document elements is dependent upon
  knowledge of the namespaces of the elements.
Note about elementFormDefault and xpath Expressions

We have seen how to design your schema so that elementFormDefault acts as an “exposure
switch”. Simply change the value of elementFormDefault and it dictates whether or not elements
are qualified in instance documents. In general, no other changes are needed in the schema other
than changing the value of elementFormDefault. However, if your schema is using <key> or
<unique> then you will need to make modifications to the xpath expressions when you change
the value of elementFormDefault.

If elementFormDefault=“qualified” then you must qualify all the references in the xpath
expression.
Example:

<xsd:key name=“PK”>

 <xsd:selector xpath=“c:Camera/c:lens”>

 <xsd:field xpath=“c:zoom”>

</xsd:key>

Note that each element in the xpath expression is namespace-qualified.

If elementFormDefault=“unqualified” then you must NOT qualify the references in the xpath
expression.
Example:

<xsd:key name=“PK”>

 <xsd:selector xpath=“Camera/lens”>

 <xsd:field xpath=“zoom”>

</xsd:key>

Note that none of the elements in the xpath expressions are namespace-qualified.

So, as you switch between exposing and hiding namespaces you will need to take the xpath
changes into account.




                                               21

More Related Content

What's hot

ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgePVS-Studio
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.Dragos Mihai Rusu
 
Jasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyJasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyIgor Napierala
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascriptmpnkhan
 
Even Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax ExperienceEven Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax ExperienceSteve Souders
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJWORKS powered by Ordina
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the ASTJarrod Overson
 

What's hot (9)

ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.
 
Jsp
JspJsp
Jsp
 
Jasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishyJasmine - why JS tests don't smell fishy
Jasmine - why JS tests don't smell fishy
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
Effecient javascript
Effecient javascriptEffecient javascript
Effecient javascript
 
Even Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax ExperienceEven Faster Web Sites at The Ajax Experience
Even Faster Web Sites at The Ajax Experience
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
 
JavaScript and the AST
JavaScript and the ASTJavaScript and the AST
JavaScript and the AST
 

Similar to Hide Versus Expose

Zero One Or Many Namespaces
Zero One Or Many NamespacesZero One Or Many Namespaces
Zero One Or Many NamespacesLiquidHub
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorMark Leith
 
Expanding a tree node
Expanding a tree nodeExpanding a tree node
Expanding a tree nodeHemakumar.S
 
Mazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsMazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsCardinaleWay Mazda
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handlingSuite Solutions
 
RomaFramework Tutorial Basics
RomaFramework Tutorial BasicsRomaFramework Tutorial Basics
RomaFramework Tutorial BasicsLuca Garulli
 
Exploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsExploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsMarian Marinov
 
07 Collada Overview
07 Collada Overview07 Collada Overview
07 Collada Overviewjohny2008
 
Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18HUST
 
Improving Soap Message Serialization
Improving Soap Message SerializationImproving Soap Message Serialization
Improving Soap Message SerializationPrabath Siriwardena
 
Best Practice In Nutshell
Best Practice In NutshellBest Practice In Nutshell
Best Practice In NutshellLiquidHub
 
Devclub Servicemix Jevgeni Holodkov 23 04 09
Devclub Servicemix Jevgeni Holodkov 23 04 09Devclub Servicemix Jevgeni Holodkov 23 04 09
Devclub Servicemix Jevgeni Holodkov 23 04 09helggeist
 
Step by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts ApplicationStep by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts Applicationelliando dias
 
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]Chris Toohey
 

Similar to Hide Versus Expose (20)

Zero One Or Many Namespaces
Zero One Or Many NamespacesZero One Or Many Namespaces
Zero One Or Many Namespaces
 
Ridingapachecamel
RidingapachecamelRidingapachecamel
Ridingapachecamel
 
Extending MySQL Enterprise Monitor
Extending MySQL Enterprise MonitorExtending MySQL Enterprise Monitor
Extending MySQL Enterprise Monitor
 
Expanding a tree node
Expanding a tree nodeExpanding a tree node
Expanding a tree node
 
Download It
Download ItDownload It
Download It
 
Mazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml ToolsMazda Use of Third Generation Xml Tools
Mazda Use of Third Generation Xml Tools
 
Sax Dom Tutorial
Sax Dom TutorialSax Dom Tutorial
Sax Dom Tutorial
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
 
Sinatra
SinatraSinatra
Sinatra
 
RomaFramework Tutorial Basics
RomaFramework Tutorial BasicsRomaFramework Tutorial Basics
RomaFramework Tutorial Basics
 
Exploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your pluginsExploiting the newer perl to improve your plugins
Exploiting the newer perl to improve your plugins
 
JSON Viewer XPATH Workbook
JSON Viewer XPATH WorkbookJSON Viewer XPATH Workbook
JSON Viewer XPATH Workbook
 
07 Collada Overview
07 Collada Overview07 Collada Overview
07 Collada Overview
 
Csphtp1 18
Csphtp1 18Csphtp1 18
Csphtp1 18
 
Improving Soap Message Serialization
Improving Soap Message SerializationImproving Soap Message Serialization
Improving Soap Message Serialization
 
Best Practice In Nutshell
Best Practice In NutshellBest Practice In Nutshell
Best Practice In Nutshell
 
Spring Surf 101
Spring Surf 101Spring Surf 101
Spring Surf 101
 
Devclub Servicemix Jevgeni Holodkov 23 04 09
Devclub Servicemix Jevgeni Holodkov 23 04 09Devclub Servicemix Jevgeni Holodkov 23 04 09
Devclub Servicemix Jevgeni Holodkov 23 04 09
 
Step by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts ApplicationStep by Step Guide for building a simple Struts Application
Step by Step Guide for building a simple Struts Application
 
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
 

More from 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
 

More from 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
 

Recently uploaded

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Recently uploaded (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 

Hide Versus Expose

  • 1. Hide (Localize) Namespaces Versus Expose Namespaces Table of Contents Issue Introduction Example Technical Requirements for Hiding (Localizing) Namespaces Best Practice Issue When should a schema be designed to hide (localize) within the schema the namespaces of the elements and attributes it is using, versus when should it be designed to expose the namespaces in instance documents? Introduction A typical schema will reuse elements and types from multiple schemas, each with different namespaces. <xsd:schema … <xsd:schema … targetNamespace=“A”> targetNamespace=“B”> A.xsd B.xsd <xsd:schema … targetNamespace=quot;Cquot;> <xsd:import namespace=quot;Aquot; schemaLocation=quot;A.xsdquot;/> <xsd:import namespace=quot;Bquot; schemaLocation=quot;B.xsdquot;/> … </xsd:schema> C.xsd 12
  • 2. A schema, then, may be comprised of components from multiple namespaces. Thus, when a schema is designed the schema designer must decide whether or not the origin (namespace) of each element should be exposed in the instance documents. Instance Document <myDoc … schemaLocation=“C C.xsd”> </myDoc> The namespaces of the components are not visible in the instance documents. Instance Document <myDoc … schemaLocation=“C C.xsd”> </myDoc> The namespaces of the components are visible in the instance documents. 13
  • 3. A binary switch attribute in the schema is used to control the hiding/exposure of namespaces: by setting elementFormDefault=“unqualified” the namespaces will be hidden (localized) within the schema, and by setting elementFormDefault=“qualified” the namespaces will be exposed in instance documents. elementFormDefault - the Exposure “Switch” Schema hide expose elementFormDefault <xsd:schema … <xsd:schema … vs elementFormDefault=“qualified”> elementFormDefault=“unqualified”> Example: Nikon.xsd Pentax.xsd Olympus.xsd Camera.xsd Below is a schema for describing a camera. The camera schema reuses components from other schemas - the camera’s <body> element reuses a type from the Nikon schema, the camera’s <lens> element reuses a type from the Olympus schema, and the camera’s <manual_adaptor> element reuses a type from the Pentax schema. 14
  • 4. Camera.xsd <?xml version=quot;1.0quot;?> <xsd:schema xmlns:xsd=quot;http://www.w3.org/2001/XMLSchemaquot; targetNamespace=quot;http://www.camera.orgquot; xmlns:nikon=quot;http://www.nikon.comquot; xmlns:olympus=quot;http://www.olympus.comquot; xmlns:pentax=quot;http://www.pentax.comquot; elementFormDefault=quot;unqualifiedquot;> <xsd:import namespace=quot;http://www.nikon.comquot; schemaLocation=quot;Nikon.xsdquot;/> <xsd:import namespace=quot;http://www.olympus.comquot; schemaLocation=quot;Olympus.xsdquot;/> <xsd:import namespace=quot;http://www.pentax.comquot; schemaLocation=quot;Pentax.xsdquot;/> <xsd:element name=quot;cameraquot;> <xsd:complexType> <xsd:sequence> <xsd:element name=quot;bodyquot; type=quot;nikon:body_typequot;/> <xsd:element name=quot;lensquot; type=quot;olympus:lens_typequot;/> <xsd:element name=quot;manual_adapterquot; type=quot;pentax:manual_adapter_typequot;/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> This schema is designed to hide namespaces Note the three <import> elements for importing the Nikon, Olympus, and Pentax components. Also note that the <schema> attribute, elementFormDefault has been set to the value of unqualified. This is a critical attribute. Its value controls whether the namespaces of the elements being used by the schema will be hidden or exposed in instance documents (thus, it behaves like a switch turning namespace exposure on/off). Because it has been set to “unqualified” in this schema, the namespaces will be remain hidden (localized) within the schema, and will not be visible in instance documents, as we see here: 15
  • 5. Camera.xml (namespaces hidden) Instance Document <?xml version=quot;1.0quot;?> <my:camera xmlns:my=quot;http://www.camera.orgquot; xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot; xsi:schemaLocation= quot;http://www.camera.org Camera.xsdquot;> <body> <body> Instance document with namespaces hidden <description>Ergonomically designed casing for easy handling</description> <description>Ergonomically designed casing for easy handling</descriptio </body> </body> (localized) within the schema <lens> <lens> <zoom>300mm</zoom> <zoom>300mm</zoom> <f-stop>1.2</f-stop> <f-stop>1.2</f-stop> </lens> </lens> <manual_adapter> <manual_adapter> <speed>1/10,000 sec to 100 sec</speed> <speed>1/10,000 sec to 100 sec</speed> </manual_adapter> </manual_adapter> </my:camera> Instance document with namespaces hidden (localized) in the schema. --> The fact that the <description> element comes from the Nikon schema, the <zoom> and <f-stop> elements come from the Olympus schema, and the <speed> element comes from the Pentax schema is totally transparent to the instance document. The only namespace qualifier exposed in the instance document is on the <camera> root element. The rest of the document is completely free of namespace qualifiers. The Nikon, Olympus, and Pentax namespaces are completely hidden (localized) within the schema! Looking at the instance document one would never realize that the schema got its components from three other schemas. Such complexities are localized to the schema. Thus, we say that the schema has been designed in such a fashion that its component namespace complexities are “hidden” from the instance document. On the other hand, if the above schema had set elementFormDefault=“qualified” then the namespace of each element would be exposed in instance documents. Here’s what the instance document would look like: 16
  • 6. Camera.xml (namespaces exposed) Instance Document <?xml version=quot;1.0quot;?> <c:camera xmlns:c=quot;http://www.camera.orgquot; xmlns:nikon=quot;http://www.nikon.comquot; xmlns:olympus=quot;http://www.olympus.comquot; xmlns:pentax=quot;http://www.pentax.comquot; xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot; xsi:schemaLocation= quot;http://www.camera.org Camera.xsd> <c:body> <nikon:description>Ergonomically designed casing for easy handling</nikon:description> handling</nikon:description> </c:body> <c:lens> <olympus:zoom>300mm</olympus:zoom> <olympus:zoom>300mm</olympus:zoom> <olympus:f-stop>1.2</olympus:f-stop> <olympus:f-stop>1.2</olympus:f-stop> </c:lens> <c:manual_adapter> <pentax:speed>1/10,000 sec to 100 sec</pentax:speed> <pentax:speed>1/10,000 sec to 100 sec</pentax:speed> </c:manual_adapter> </c:camera> Instance document with namespaces exposed Note that each element is explicitly namespace-qualified. Also, observe the declaration for each namespace. Due to the way the schema has been designed, the complexities of where the schema obtained its components have been “pushed out” to the instance document. Thus, the reader of this instance document is “exposed” to the fact that the schema obtained the description element from the Nikon schema, the zoom and f-stop elements from the Olympus schemas, and the speed element from the Pentax schema. All Schemas must have a Consistent Value for elementFormDefault! Be sure to note that elementFormDefault applies just to the schema that it is in. It does not apply to schemas that it includes or imports. Consequently, if you want to hide namespaces then all schemas involved must have set elementFormDefault=“unqualified”. Likewise, if you want to expose namespaces then all schemas involved must have set elementFormDefault=“qualified”. To see what happens when you “mix” elementFormDefault values, let’s suppose that Camera.xsd and Olympus.xsd have both set in their schema elementFormDefault=“unqualified”, whereas Nikon.xsd and Pentax.xsd have both set elementFormDefault=“qualified”. 17
  • 7. element FormDefault= quot;unqualifiedquot; Olympus.xsd elementFormDefault= quot;qualifiedquot; element FormDefault=quot;qualifiedquot; Pentax.xsd Nikon.xsd elementFormDefault= quot;unqualified quot; Camera.xsd Here’s what an instance document looks like with this “mixed” design: Camera.xml (mixed design) Instance Document <?xml version=quot;1.0quot;?> <my:camera xmlns:my=quot;http://www.camera.orgquot; xmlns:nikon=quot;http://www.nikon.comquot; xmlns:pentax=quot;http://www.pentax.comquot; xmlns:xsi=quot;http://www.w3.org/2001/XMLSchema-instancequot; xsi:schemaLocation= quot;http://www.camera.org Camera.xsd> <body> <body> Instance document with namespaces hidden <description>Ergonomically designed designed casing for easy <nikon:description>Ergonomically designed casing for easy <nikon:description>Ergonomically casing for easy handling</description> handling</nikon:description> handling</nikon:description> (localized) within the schema </body> </body> <lens> <lens> <zoom>300mm</zoom> <olympus:zoom>300mm</olympus:zoom> <olympus:zoom>300mm</olympus:zoom> <f-stop>1.2</f-stop> <olympus:f-stop>1.2</olympus:f-stop> <olympus:f-stop>1.2</olympus:f-stop> </lens> </lens> <manual_adapter> <manual_adapter> <speed>1/10,000 sec to 100 sec</speed> <pentax:speed>1/10,000 sec to 100 sec</pentax:speed> <pentax:speed>1/10,000 sec to 100 sec</pentax:speed> </manual_adapter> </manual_adapter> </my:camera> Hiding/exposure mix: This instance document has the Nikon and Pentax namespaces exposed, while the Camera and Olympus namespaces are hidden. 18
  • 8. Observe that in this instance document some of the elements are namespace-qualified, while others are not. Namely, those elements from the Camera and Olympus schemas are not qualified, whereas the elements from the Nikon and Pentax schemas are qualified. Technical Requirements for Hiding (Localizing) Namespaces There are two requirements on an element for its namespace to be hidden from instance documents: [1] The value of elementFormDefault must be “unqualified”. [2] The element must not be globally declared. For example: <?xml version=“1.0”?> <xsd:schema ...> <xsd:element name=“foo”> ... </xsd:schema ...> The element foo can never have its namespace hidden from instance documents, regardless of the value of elementFormDefault. foo is a global element (i.e., an immediate child of <schema>) and therefore must always be qualified. To enable namespace hiding the element must be a local element. Best Practice For this issue there is no definitive Best Practice with respect to whether to design your schemas to hide/localize namespaces, or design it to expose namespaces. Sometimes it’s best to hide the namespaces. Othertimes it’s best to expose the namespaces. Both have their pluses and minus, as is discussed below. However, there are Best Practices with regards to other aspects of this issue. They are: 1. Whenever you create a schema, make two copies of it. The copies should be identical, except that in one copy set elementFormDefault=“qualified”, whereas in the other copy set elementFormDefault=“unqualified”. If you make two versions of all your schemas then people who use your schemas will be able to implement either design approach - hide (localize) namespaces, or expose namespaces. 2. Minimize the use of global elements and attributes so that elementFormDefault can behave as an “exposure switch”. The rationale for this was described above, in Technical Requirements for Hiding (Localizing) Namespaces Advantages of Hiding (Localizing) Component Namespaces within the Schema The instance document is simple. It’s easy to read and understand. There are no namespace qualifiers cluttering up the document, except for the one on the document element (which is okay because it shows the domain of the document). The knowledge of where the schema got its components is irrelevant and localized to the schema. 19
  • 9. Design your schema to hide (localize) namespaces within the schema ... – when simplicity, readability, and understandability of instance documents is of utmost importance when namespaces in the instance document provide no necessary additional information. In many scenarios the users of the instance documents are not XML-experts. Namespaces would distract and confuse such users, where they are just concerned about structure and content. – when you need the flexibility of being able to change the schema without impact to instance documents. To see this, imagine that when a schema is originally designed it imports elements/ types from another namespace. Since the schema has been designed to hide (localize) the namespaces, instance documents do not see the namespaces of the imported elements. Then, imagine that at a later date the schema is changed such that instead of importing the elements/ types, those elements and types are declared/defined right within the schema (inline). This change from using elements/types from another namespace to using elements/types in the local namespace has no impact to instance documents because the schema has been designed to shield instance documents from where the components come from. Advantages of Exposing Namespaces in Instance Documents If your company spends the time and money to create a reusable schema component, and makes it available to the marketplace, then you will most likely want recognition for that component. Namespaces provide a means to achieve recognition. For example, <nikon:description> Ergonomically designed casing for easy handling</ nikon:description> There can be no misunderstanding that this component comes from Nikon. The namespace qualifier is providing information on the origin/lineage of the description element. Another case where it is desirable to expose namespaces is when processing instance documents. Oftentimes when processing instance documents the namespace is required to determine how an element is to be processed (e.g., “if the element comes from this namespace then we’ll process it in this fashion, if it comes from this other namespace then we’ll process it in a different fashion”). If the namespaces are hidden then your application is forced to do a lookup in the schema for every element. This will be unacceptably slow. Design your schema to expose namespaces in instance documents ... – when lineage/ownership of the elements are important to the instance document users (such as for copyright purposes). – when there are multiple elements with the same name but different semantics then you may want to namespace-qualify them so that they can be differentiated (e.g, publisher:body versus human:body). [In some cases you have multiple elements with the same name and different semantics but the context of the element is sufficient to determine its semantics. Example: the title element in <person><title> is easily distinguished from the title element in <chapter><title>. In such cases there is less justification for designing your schema to expose the namespaces.] 20
  • 10. – when processing (by an application) of the instance document elements is dependent upon knowledge of the namespaces of the elements. Note about elementFormDefault and xpath Expressions We have seen how to design your schema so that elementFormDefault acts as an “exposure switch”. Simply change the value of elementFormDefault and it dictates whether or not elements are qualified in instance documents. In general, no other changes are needed in the schema other than changing the value of elementFormDefault. However, if your schema is using <key> or <unique> then you will need to make modifications to the xpath expressions when you change the value of elementFormDefault. If elementFormDefault=“qualified” then you must qualify all the references in the xpath expression. Example: <xsd:key name=“PK”> <xsd:selector xpath=“c:Camera/c:lens”> <xsd:field xpath=“c:zoom”> </xsd:key> Note that each element in the xpath expression is namespace-qualified. If elementFormDefault=“unqualified” then you must NOT qualify the references in the xpath expression. Example: <xsd:key name=“PK”> <xsd:selector xpath=“Camera/lens”> <xsd:field xpath=“zoom”> </xsd:key> Note that none of the elements in the xpath expressions are namespace-qualified. So, as you switch between exposing and hiding namespaces you will need to take the xpath changes into account. 21