MyArticle » Computers » Programming » A Great Explanation To Do With Namespaces In XML

A Great Explanation To Do With Namespaces In XML


View PDF | Print View
by: michaeldupre
Total views: 62
Word Count: 626
Date: Thu, 21 Jul 2011 Time: 3:25 AM

Hey there, i'm called Michael Dupre. Thanks for visiting my '5 minute XML' tutorials in which I provide you with regular byte size courses.

The current matter is for people who happen to be not used to XML.

Exactly what constitutes a correct XML name was in fact briefly covered within a past 5 minute tutorial. This type of an XML name in its self is not necessarily always good enough, however. Cases can potentially show up where XML names may well turned out to be unclear. Suppose, for example, that a few or perhaps even more XML files are combined.

The files could possibly feature more than one author and even at very least one of the XML names might possibly have been defined in much more than one of the combined files. This creates a prospective conflict. In order to exhibit the problem look into the following mark-up:

[table]

 [tr]

 [td>item1</td]

 [td]item2[/td]

 [/tr]

[/table]

[table]

 [name]Dining Room Table[/name]

 [length]2000[/length]

 [width]1000[/width]

 [height]500[/height]

[/table]

When there's only one ‘table’ component described, we have now lucidity. As soon as we combine a second ‘table’ element description next to the first, we're no longer able to ascertain the meaning of one from the other.

The actual circumstance in which the two element meanings operate now usually requires even more qualification. We can easily, of course, rename one of the conflicting elements but in an enormous document and also where there could be lots of such identical names, this is definitely no longer a realistic exercise.

The problem is resolved put simply utilizing ‘namespaces’. Namespaces not only presents differentiation between identical XML names additionally it is takes on the key duty of making distinct groups to which XML entities belong.

[root]

xmlns:h="http://www.w3.org/TR/html4/"

xmlns:ct="http://www.thefurniturestore.com/coffeetables"]

 [h:table]

 [h:tr]

 [h:td]item1[/h:td]

 [h:td]item2[/h:td]

 [/h:tr]

 [/h:table]

 [ct:table]

 [ct:name]Dining Room Table[/ct:name]

 [ct:length]2000[/ct:length]

 [ct:width]1000[/ct:width]

 [ct:height]500[/ct:height]

 [/ct:table]

[/root]

The way in which namespaces work is that each element (or attribute) definition is designated a prefix. This is certainly divided from what is known as the ‘local part’ of the name, by a singular colon (as shown above). It is not uncommon procedure to link a prefix with a URI (or Uniform Resource Indicator).

The most frequent kind is a URL (or Uniform Resource Locator). The URI is not used with regard to lookup over the internet. Its usage is usually solely to identify a set of data items uniquely and since URI’s are used globally they are perfect for the job. URI’s are bound to a namespace prefix by using the

xmlns:prefix="URI".

The prefix additionally, the full URI characterization will not be exchangeable as URI’s can have characters which are illegal within the XML namespace. Additionally, it is illegal to implement the three letters XML in any case arrangement for a namespace prefix simply because these are earmarked.

I really hope this has gone someway to introduce the concept of namespaces but I highly advocate further looking at on this topic, as with all my 5 minute XML tutorials.

An abundance of details are available on XML those of you that would choose to understand more. For the definitive guide, visit www.W3.org.

Let's hope the above mentioned is beneficial to somebody out there. Extra written content will likely be on its way shortly.













































































































About the Author

Michael Dupre is really an veteran authority in XML coding and also XML standards and has an array of working understanding of XML Editor in addition to functional know how with XML Schema Editor.



Latest Articles about: Programming


Popular Articles about: Programming




Rating: Not yet rated


??????