January 28, 2010

0 XML ADVANCED



XML ADVANCED

XmlNamespaces

XML namespaces provide a method to avoid element name conflicts.

Name conflicts

Since element names in XML are not predefined, a name conflict will occur when two different documents use the same element names.

This XML document carries information in a table:

<table>
<tr>
<td>Apples</td>
</tr>
</td>


This XML document carries information about a table ( a piece of information ):

<table>
<name>African Coffee Table</name>
<length>120</length>
</table>

If these two XML documents were added together, there would be an element name conflict because both documents contain a <table> element with different content and defintion.

Solving Name conflicts using a Prefix

This XML document carrries information in a table:

<h:table>
<h:tr>
<h:td>
</h:tr>
</h:table>

This XML document carries information about a piece of furniture:

<f:table>
<f:name>African coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>

Now there will be no name conflict because the two documents use a different name for their <table> element (<h:table> and <f:table>).

By using a prefix, we have created two different types of <table> elements.

0 comments:

Post a Comment

Blogger Themes

 
Powered by Blogger