Batky-Howell
Contact UsSite Map
Private/Customized TrainingOpen Entrollment Public Training

TRAINING COURSES

AJAX Training
Business Analyst Training
C and C++ Training
Java Training
J2EE Training
Linux Training
.NET Training
Object-Oriented Training
Oracle Training
Perl and Ruby Training
UNIX Training
XML and Web Services Training

 

Instructor Insights
Public Schedule
Private/Customized Training
Customers
Testimonials
What's New
FAQ
Newsletter
Contact Us
Employment
Student Resources
                Order Courseware                Search Courses 

XML - Instructor Insights


Our instructors have real-world experience in the technologies that they teach. Here they share their insights and discoveries on working with each of these technologies.

XML Namespaces
Even though the Namespace Name is typically a URI, it does not have to resolve to any real resource.

	<tns:rootElement xmlns:tns="http://www.batky-howell.com/NonExistentResource">
 	. . .
	</tns:rootElement>
	
Two namespace declarations that use the same namespace name are considered equivalent, regardless of the prefix they map to. Therefore, you should use a unique namespace name for each unique declaration. Since each organization has a unique domain name, it is a logical choice for inclusion within a namespace name, especially if you plan to use XML content from different organizations. No resource is expected to be located at the URI that your namespace name references. Namespaces function no differently if you have an active connection to the Internet or not. That being said, some people find that it is convenient to place documentation, especially XML Schema, at the URI referenced by the namespace declaration.
Validation

Use W3C XML Schema to validate an element that contains both simple and complex content.

The XML Schema recommendation breaks elements into two categories based on their content: simple types and complex types. Simple types contain only text content. Complex types contain attributes and/or subelements.

In the following example, the course element is complex and the name element is simple:

	<training-course days="3">
	  <name>Introduction to XML<name>	  
	<training-course>

The corresponding XML Schema for the above example could look something like this:

	<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	  <xsd:element name="training-course" type="CourseType" />
	  
	  <xsd:complexType name="CourseType">
	    <xsd:sequence>
	        <xsd:element name="name" type="xsd:string"/>
	    <xsd:sequence>
	    <xsd:attribute name="days" type="xsd:int"/>
	  <xsd:complexType>
	<xsd:schema>

If the name element also contained an attribute, then it becomes a complex type with simple content.

	<training-course days="3">
	  <name category="XML Training">Introduction to XML<name>	  
	<training-course>

The Schema must now be:

	
	<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	  <xsd:element name="training-course" type="CourseType" />

	  <xsd:complexType name="CourseType">
	    <xsd:sequence>
	      <xsd:element name="name" type="NameType"/>
	    <xsd:sequence>
	    <xsd:attribute name="days" type="xsd:int"/>
	  <xsd:complexType>

	  <xsd:complexType name="NameType">
	    <xsd:simpleContent>
	      <xsd:extension base="xsd:string">
	        <xsd:attribute name="category" type="xsd:string"/>
	      <xsd:extension>
	    <xsd:simpleContent>
	  <xsd:complexType>
	<xsd:schema>

There is a new complexType element called NameType. It has a simpleContent child because a name contains only text. The content of a name is a string, but it also has an attribute called category. This is expressed using the xsd:attribute within the xsd:extension element.