| By Tony Gupta | Article Rating: |
|
| September 21, 2011 07:15 AM EDT | Reads: |
1,287 |
Here is my 'five-minute XML' series where by I give you scheduled byte size guides.
Today's issue is good for those people who happen to be starting out with XML.
In "XML Schema - Overview" (5 Minute XML #7), I reported the need for a schema definition language. I defined principle syntax for the purpose of indicating the namespace from the schema document and W3C URI (for referencing components and attributes not defined from the targetNamespace).
In conclusion I referred to the following schema attribute: <xs:schema elementFormDefault="qualified" ...>.
Here, I am hoping to explain precisely why and how this attribute is used and additionally precisely what influences it brings to bear.

Put simply an XML schema is seen as a group of rules or specification if you like, that the programmer would likely make use of to spell out the structure of an XML document. One example is with a database schema will describe the data which can be within a database (table structure, data types, etc.) An XML Schema is a lot the same for an XML document, it is effectively a rule set.
A schema itself might be contains components from a variety of schemas each in its own namespace. A schema developer will have to make a decision whether or not to uncover or possibly conceal these namespaces to the instance document. The elementFormDefault schema attribute allows them to do just this.
Setting elementFormDefault="unqualified" (the default) will hide (or localise) the namespaces, while setting it to "qualified" definitely will expose the namespaces outlined in the schema to the instance document.
Such as the schema below describes a car which sources components through three or more other schemas. The chassis, wheels and interior are generally resulting from individual makers.
Car.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="*.w3.org/2001/XMLSchema"
targetNamespace="*.car.org"
xmlns="*.car.org"
xmlns:ford="*.ford.com"
xmlns:toyota="*.toyota.com"
xmlns:audi="*.audi.com"
elementFormDefault="unqualified">
<xsd:import namespace="*.ford.com"
schemaLocation="Ford.xsd"/>
<xsd:import namespace="*.toyota.com"
schemaLocation="Toyota.xsd"/>
<xsd:import namespace="*.audi.com"
schemaLocation="Audi.xsd"/>
<xsd:element name="camera">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="chassis" type="Ford:chassis"/>
<xsd:element name="wheels" type="Toyota:wheels"/>
<xsd:element name="interior" type="Audi:interior"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Take note the import elements. These accept entry to elements via the diverse manufacturers. Word moreover that the schema attribute elementFormDefault will be set to unqualified. This process covers the many different manufacturers' namespaces from virtually any instance document. Such an instance record may possibly look and feel something like this:
Car.xml
<?xml version="1.0"?>
<my:car xmlns:my="http://www.car.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.car.org Car.xsd">
<chassis>
<description>
Ford F-Series F-150 Regular Cab 2WD
</description>
</chassis>
<wheels alloys="true">
<tyres>Pirelli P3000</tyres>
</wheels>
<interior>
<seatCoverMaterial>leather</seatCoverMaterial>
</interior>
</my:camera>
Only the car root element namespace qualifier is subjected in the instance record, above. The various car brands providing the actual numerous components are at this point concealed or ‘localized' to the schema definition. The instance file doesn't worry itself with where the components are usually taken from. Just that they are accessible.
If, on the other hand, elementFormDefault was indeed set to qualified we would probably have a different story...
These will probably be introduced in another 5 Minute XML article.
A large cornucopia of info is available on the subject of XML for folks who would choose to understand more. For the definitive guide, visit www.W3.org.
Hopefully the above mentioned is beneficial to somebody out there. Much more information will be coming very soon.
Published September 21, 2011 Reads 1,287
Copyright © 2011 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Tony Gupta
Tony Gupta has worked in the world of IT for almost 20 years now with a special emphasis on XML and web standards technologies since 1994 when XML started to take off. In his personal life he enjoys motor racing and prestige cars. He is also a part-time property developer and has a real passion for renovating old barns.
- SharePoint 2010 Development with Silverlight Book Review
- How MRP and Production Planning and Scheduling Software Differ
- Book Review: Decision Management Systems
- Planning, Scoping and Recon Techniques
- Bluegiga Enables the Development of Bluetooth® 4.0 Accessories for iPhone 4S
- XML Security Gateway plugging holes for Public Clouds
- Bluegiga facilite le développement d'accessoires Bluetooth® 4.0 pour iPhone 4S
- Bluegiga ermöglicht die Entwicklung von Bluetooth® 4.0 Zubehör für das iPhone 4S
- Learn Open Source Database Tools from Stanford for Free
- Software Architecture: A Comprehensive Framework and Guide for Practitioners Book Review
- WGU Washington Doubles Enrollment in First Six Months
- Microsoft Lightswitch Training in Bengaluru
- Service Design Patterns: Fundamental Design Solutions for SOAP/WSDL
- SharePoint 2010 Development with Silverlight Book Review
- The New ROI: A Return on Innovation, and Using Data to Do It
- Reading an Attribute from an LDAP Directory
- How MRP and Production Planning and Scheduling Software Differ
- Book Review: Decision Management Systems
- Planning, Scoping and Recon Techniques
- Bluegiga Enables the Development of Bluetooth® 4.0 Accessories for iPhone 4S
- XML Security Gateway plugging holes for Public Clouds
- Bluegiga facilite le développement d'accessoires Bluetooth® 4.0 pour iPhone 4S
- Bluegiga ermöglicht die Entwicklung von Bluetooth® 4.0 Zubehör für das iPhone 4S
- Rawa Ruska
- Where Are RIA Technologies Headed in 2008?
- Processing XML with C# and .NET
- AJAX World RIA Conference & Expo Kicks Off in New York City
- JSON vs XML - A Jason vs Freddie Sequel
- Has the Technology Bounceback Begun?
- i-Technology Viewpoint: The Very Confused World of 3D and XML
- BPEL Processes and Human Workflow
- The Top 250 Players in the Cloud Computing Ecosystem
- The Top 250 Players in the Cloud Computing Ecosystem
- Generating XML from Relational Database Tables
- Open Source Database Special Feature: An Introduction to Berkeley DB XML
- "HP's Problem Ain't the SAP Install," Says Sun's Schwartz





















