tag:blogger.com,1999:blog-33909979725269341922024-03-13T05:56:14.702-07:00Web Developmentrajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.comBlogger29125tag:blogger.com,1999:blog-3390997972526934192.post-23419685794881898672010-01-28T07:58:00.000-08:002011-01-15T00:59:39.643-08:00XML, NameSpaces<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_sT3hnOr4kDU/S_Y-_xUWvNI/AAAAAAAAAFo/OsSIv-lNSCs/s1600/intense-debate.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://2.bp.blogspot.com/_sT3hnOr4kDU/S_Y-_xUWvNI/AAAAAAAAAFo/OsSIv-lNSCs/s320/intense-debate.PNG" width="320" /></a></div><br />
<br />
<span style="color: #ff6600; font-weight: bold;">The XML namespace attribute is placed in the start tag of an element and has the following syntax:</span><br />
<br />
<span style="color: #ff6600; font-weight: bold;">xmlns:namespace-prefix="namespaceURI"</span><br />
<br />
<span style="color: #ff6600; font-weight: bold;">When a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with the same namespace.</span><br />
<br />
<span style="color: #ff6600; font-weight: bold;">Note that the address used to identify the namespace is nto used by the parser to look up information. The only purpose is to give the namespace a unique name. However, very often companies use the namespace as a pointer to a real Web page containing</span><br />
<span style="color: #ff6600; font-weight: bold;">information about the name space.</span><br />
<br />
<span style="color: #ff6600; font-weight: bold;">XML allows document authors to create custom elements. This extensibility can result in<br />
naming collisions among elements in an XML document that each have the same name.<br />
For example, we may use the element book to mark up data about a Deitel publication. A<br />
stamp collector may use the element book to mark up data about a book of stamps. Using<br />
both of these elements in the same document could create a naming collision, making it<br />
difficult to determine which kind of data each element contains.</span><br />
<span style="color: #ff6600; font-weight: bold;"><br />
An XML namespace is a collection of element and attribute names. XML namespaces<br />
provide a means for document authors to unambiguously refer to elements with the same<br />
name (i.e., prevent collisions). </span><br />
<br />
<span style="color: #ff6600; font-weight: bold;">For example,<subject>Geometry</subject><br />
and <subject>Cardiology</subject> use element subject to mark up data. In the first case, the subject is something one studies in school, whereas in the second case, the subject is a field of medicine. </span><br />
<span style="color: #ff6600; font-weight: bold;">Namespaces can differentiate these two subject elements—for example:<br />
<highschool:subject>Geometry</highschool:subject>and<medicalschool:subject>Cardiology</medicalschool:subject></span><br />
<span style="color: #ff6600; font-weight: bold;"><br />
Both highschool and medicalschool are namespace prefixes. A document author places<br />
a namespace prefix and colon (:) before an element name to specify the namespace to<br />
which that element belongs. Document authors can create their own namespace prefixes<br />
using virtually any name except the reserved namespace prefix xml. In the next subsections,<br />
we demonstrate how document authors ensure that namespaces are unique.</span><br />
<br />
<span style="color: #ff6600; font-weight: bold;">Common Programming Error 12.7<br />
Attempting to create a namespace prefix named xml in any mixture of uppercase and lowercase<br />
letters is a syntax error—the xml namespace prefix is reserved for internal use by XML itself. 12.7<br />
<br />
Differentiating Elements with Namespaces<br />
<br />
Figure 12.7 demonstrates namespaces. In this document, namespaces differentiate two<br />
distinct elements—the file element related to a text file and the file document related<br />
to an image file.<br />
<br />
1 <br />
2<br />
3<!-- Fig. 12.7: namespace.xml --><br />
4 <!-- Demonstrating namespaces --><br />
5 <text:directory><br />
6 xmlns:text = "urn:deitel:textInfo"<br />
7 xmlns:image = "urn:deitel:imageInfo"><br />
8</text:directory></span><br />
<span style="color: #ff6600; font-weight: bold;">9<text:file filename="book.xml"><br />
10 <text:description>A book list</text:description><br />
11 </text:file><br />
12<br />
13 <image:file filename="funny.jpg"><br />
14 <image:description>A funny picture</image:description><br />
15 <image:size height="100" width="200"><br />
16 </image:size><br />
17 </image:file><br />
Fig. 12.7 </span><br />
<span style="color: #ff6600; font-weight: bold;"> </span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_sT3hnOr4kDU/TTFerMwOXMI/AAAAAAAAAPk/NiEWw6Uw1SA/s1600/FIG+12.7+.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="http://2.bp.blogspot.com/_sT3hnOr4kDU/TTFerMwOXMI/AAAAAAAAAPk/NiEWw6Uw1SA/s320/FIG+12.7+.JPG" width="320" /></a></div><span style="color: #ff6600; font-weight: bold;"> </span><br />
<div style="text-align: center;"><span style="color: #ff6600; font-weight: bold;"> <span style="font-size: large;">Fig. 12.7 | XML namespaces demonstration.</span></span></div><div style="text-align: center;"><br />
</div><div style="text-align: center;"><br />
</div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;">Lines 6–7 use the XML-namespace reserved attribute xmlns to create two namespace<br />
prefixes—text and image. Each namespace prefix is bound to a series of characters called<br />
a Uniform Resource Identifier (URI) that uniquely identifies the namespace. Document<br />
authors create their own namespace prefixes and URIs. A URI is a way to identifying a<br />
resource, typically on the Internet. Two popular types of URI are Uniform Resource<br />
Name (URN) and Uniform Resource Locator (URL).</span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><br />
To ensure that namespaces are unique, document authors must provide unique URIs.<br />
In this example, we use the text urn:deitel:textInfo and urn:deitel:imageInfo as<br />
URIs. These URIs employ the URN scheme frequently used to identify namespaces.<br />
Under this naming scheme, a URI begins with "urn:", followed by a unique series of additional<br />
names separated by colons.</span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><br />
Another common practice is to use URLs, which specify the location of a file or a<br />
resource on the Internet. For example, www.deitel.com is the URL that identifies the<br />
home page of the Deitel & Associates website. Using URLs guarantees that the<br />
namespaces are unique because the domain names (e.g., www.deitel.com) are guaranteed<br />
to be unique. For example, lines 5–7 could be rewritten as </span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"> </span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><text:directory ></text:directory ></span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;">xmlns:text = "http://www.deitel.com/xmlns-text"<br />
xmlns:image = "http://www.deitel.com/xmlns-image"></span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><br />
where URLs related to the deitel.com domain name serve as URIs to identify the text<br />
and image namespaces. The parser does not visit these URLs, nor do these URLs need to<br />
refer to actual web pages. They each simply represent a unique series of characters used to<br />
differentiate URI names. In fact, any string can represent a namespace. For example, our<br />
image namespace URI could be hgjfkdlsa4556, in which case our prefix assignment<br />
would be</span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><br />
<span style="color: lime;">xmlns:image = "hgjfkdlsa4556"</span></span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><br />
Lines 9–11 use the text namespace prefix for elements file and description. Note<br />
that the end tags must also specify the namespace prefix text. Lines 13–16 apply<br />
namespace prefix image to the elements file, description and size. Note that attributes<br />
do not require namespace prefixes (although they can have them), because each attribute<br />
is already part of an element that specifies the namespace prefix. For example, attribute<br />
filename (line 9) is implicitly part of namespace text because its element (i.e., file) specifies<br />
the text namespace prefix. </span></span></span></div><div style="text-align: left;"><br />
</div><div style="text-align: left;"><br />
</div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><u style="color: lime;">Specifying a Default Namespace</u></span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><u style="color: lime;"> </u><br />
To eliminate the need to place namespace prefixes in each element, document authors may<br />
specify a default namespace for an element and its children. Figure 12.8 demonstrates using<br />
a default namespace (urn:deitel:textInfo) for element directory.</span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><br />
Line 5 defines a default namespace using attribute xmlns with no prefex specified, but<br />
with a URI as its value. Once we define this default namespace, child elements belonging<br />
to the namespace need not be qualified by a namespace prefix. Thus, element file (lines<br />
8–10) is in the default namespace urn:deitel:textInfo. Compare this to lines 9–10 of<br />
Fig. 12.7, where we had to prefix the file and description element names with the<br />
namespace prefix text. </span></span></span></div><div style="text-align: left;"><br />
</div><div style="text-align: left;"><br />
</div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;">1 <br />
2</span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;">3<!-- Fig. 12.8: defaultnamespace.xml --><br />
4 <!-- Using default namespaces --><br />
5 <directory xmlns="urn:deitel:textInfo"><br />
6 xmlns:image = "urn:deitel:imageInfo"><br />
7</directory></span></span></span></div><div style="text-align: left;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;">8<file filename="book.xml"><br />
9 <description>A book list</description><br />
10 </file><br />
11<br />
12 <image:file filename="funny.jpg"><br />
13 <image:description>A funny picture</image:description><br />
14 <image:size height="100" width="200"><br />
15 </image:size><br />
16 </image:file> </span></span></span></div><div style="text-align: left;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/_sT3hnOr4kDU/TTFhdJCT3tI/AAAAAAAAAPo/IdDo4LpYM7Q/s1600/FIG+12.8.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="http://3.bp.blogspot.com/_sT3hnOr4kDU/TTFhdJCT3tI/AAAAAAAAAPo/IdDo4LpYM7Q/s320/FIG+12.8.JPG" width="320" /></a></div><div style="text-align: center;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"> Fig. 12.8 | Default namespace demonstration.</span></span></span></div><div style="text-align: center;"><br />
</div><div style="text-align: center;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;">The default namespace applies to the directory element and all elements that are not<br />
qualified with a namespace prefix. However, we can use a namespace prefix to specify a<br />
different namespace for a particular element. For example, the file element in lines 12–<br />
15 includes the image namespace prefix, indicating that this element is in the<br />
urn:deitel:imageInfo namespace, not the default namespace.</span></span></span></div><div style="text-align: center;"><span style="color: #ff6600; font-weight: bold;"><span style="font-size: large;"><span style="font-size: small;"><br />
<u>Namespaces in XML Vocabularies</u><br />
XML-based languages, such as XML Schema (Section 12.6) and Extensible Stylesheet<br />
Language (XSL) (Section 12.8), often use namespaces to identify their elements. Each of<br />
these vocabularies defines special-purpose elements that are grouped in namespaces. These<br />
namespaces help prevent naming collisions between predefined elements and user-defined<br />
elements. </span> </span></span></div>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-69991892437477348252010-01-28T07:57:00.000-08:002010-05-21T01:36:20.901-07:00XML Namespace Attribute<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_sT3hnOr4kDU/S_Y-_xUWvNI/AAAAAAAAAFo/OsSIv-lNSCs/s1600/intense-debate.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://2.bp.blogspot.com/_sT3hnOr4kDU/S_Y-_xUWvNI/AAAAAAAAAFo/OsSIv-lNSCs/s320/intense-debate.PNG" width="320" /></a></div><br />
<br />
<span style="color: #ff6600; font-weight: bold;">The XML namespace attribute is placed in the start tag of an element and has the following syntax:<br />
<br />
xmlns:namespace-prefix="namespaceURI"<br />
<br />
When a namespace is defined in the start tag of an element, all child elements with the same prefix are associated with the same namespace.<br />
<br />
Note that the address used to identify the namespace is nto used by the parser to look up information. The only purpose is to give the namespace a unique name. However, very often companies use the namespace as a pointer to a real Web page containing<br />
information about the name space.<br />
<br />
</span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-70383327273154924702010-01-28T07:55:00.000-08:002010-05-21T01:36:48.192-07:00XML Uniform Resource Identifier (URI)<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/_sT3hnOr4kDU/S_Y-_xUWvNI/AAAAAAAAAFo/OsSIv-lNSCs/s1600/intense-debate.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="http://2.bp.blogspot.com/_sT3hnOr4kDU/S_Y-_xUWvNI/AAAAAAAAAFo/OsSIv-lNSCs/s320/intense-debate.PNG" width="320" /></a></div><br />
<br />
<br />
<span style="color: #ff6600; font-weight: bold;"> This XML document carries information in a table:</span><br />
<br />
<span style="color: #ff6600; font-weight: bold;"><h:table xmlns:h="http://www.w3.org/TRhtml4/"></span><br />
<span style="color: #ff6600; font-weight: bold;"><h:tr></span><br />
<span style="color: #ff6600; font-weight: bold;"><h:td>Apples</h:td></span><br />
<span style="color: #ff6600; font-weight: bold;"><h:td>Banana</h:td></span><br />
<span style="color: #ff6600; font-weight: bold;"></h:tr></span><br />
<span style="color: #ff6600; font-weight: bold;"></h:table></span><br />
<br />
<span style="color: #ff6600; font-weight: bold;">This XML document carries information about a piece of furniture:</span><br />
<br />
<span style="color: #ff6600; font-weight: bold;"><f:table xmlns:f="http://www.makemyhost.com/furniture"></span><br />
<span style="color: #ff6600; font-weight: bold;"><f:name>African Coffee Table</f:name></span><br />
<span style="color: #ff6600; font-weight: bold;"><f:width>80</f:width></span><br />
<span style="color: #ff6600; font-weight: bold;"><f:length>120</f:legnth></span><br />
<span style="color: #ff6600; font-weight: bold;"></f:table></span><br />
<br />
<span style="color: #ff6600; font-weight: bold;">Instead of using only prefixes, we have added an xmlns attribute to the <table> tag to give the prefix a qualified name associated with a name space.</span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-7845363722629513892010-01-28T07:53:00.000-08:002010-01-28T07:55:32.670-08:00XML Using Name Spaces<span style="font-weight: bold; color: rgb(255, 102, 0);"> This XML document carries information in a table:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><h:table xmlns:h="http://www.w3.org/TRhtml4/"></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><h:tr></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><h:td>Apples</h:td></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><h:td>Banana</h:td></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></h:tr></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></h:table></span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">This XML document carries information about a piece of furniture:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><f:table xmlns:f="http://www.makemyhost.com/furniture"></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><f:name>African Coffee Table</f:name></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><f:width>80</f:width></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><f:length>120</f:legnth></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></f:table></span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Instead of using only prefixes, we have added an xmlns attribute to the <table> tag to give the prefix a qualified name associated with a name space.</span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-63499830788674871302009-10-14T05:51:00.000-07:002009-10-14T05:52:39.158-07:00XML Advanced<span style="font-weight: bold; color: rgb(255, 255, 0);">XML Namespaces</span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);">XML Namespaces provide a method to avoid element name conflicts.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);">Name Conflicts</span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);">Since elment names in XML are not predefined, a name conflict will occur when two different documents use the same element names.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);">This XML document carries information in a table:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"><table></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"><tr></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"><td>Apples</td></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"><td>Bananas</td></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"></tr></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"></table></span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);">This XML document carries information about a table (a piece of furniture)</span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"><table></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"><name>African Coffee Table </name></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"><width>80</width></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"><length>120</length></span><br /><span style="font-weight: bold; color: rgb(255, 255, 0);"></table></span><br /><br /><span style="font-weight: bold; color: rgb(255, 255, 0);">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 definiton.</span>kejalhttp://www.blogger.com/profile/07909335658390396159noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-2238938708921744452009-10-14T05:43:00.000-07:002010-10-11T01:11:02.259-07:00Microsoft XML parser<div style="color: #7f6000;"><span style="font-weight: bold;">Microsoft XML parser is a COM component that comes with Internet Explorer 5 and higher. Once you have installed Internet Explorer, the parser is available to scripts.</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">Microsoft' s XML parser supports ll the necessary functions to traverse the node tree, access the nodes and their attribute values, insert and delete nodes, and convert the node tree back to XML.</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">The following table lists the most commonly used node types supported by Microsoft' s XML parser:</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;"><table border="1 " bgcolor="yello" height="500px" width="100"%></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><tr align="center"></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">Node Type </span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">Processing instruction</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">Element</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">Attribute</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">Text</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;"></tr></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><tr align="center"></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">Example</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><?xml version = "1.0"?></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><drink type = "beer"> Carlsberg</drink></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">type = "beer" </span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><td></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">Carlsberg</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"></td></span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;"></tr></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;"><tr></span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">MSXML Parser 2.5 is the XML parser that is shipped with Windows 2000 and IE 5.5.</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">MSXML Parser 3.0 is the XML parser that is shipped with IE 6.0 and Windows XP.</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">The MSXML 3.0 parser features:</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">1) Javascript, VBScript, Perl, VB, Java, C++, etc. support</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">2) Complete XML support</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">3) Full DOM and NameSpace support</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">4) DTD and validation</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">5) Complete XSLT and XPath support</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">6) SAX2 support</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">7) Server-safe HTTP</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">To create and instance of Microsoft' s XML parser with JavaScript, use the following code:</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">var xmlDoc=new ActiveXobject("Microsoft.XMLDOM")</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">To create an instance of Microsoft' s XML parser with VBScript , use the following code:</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">var xmlDoc=CreateObject("Microsoft.XMLDOM")</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">To create an instance of Microsoft's XML parser in an ASP page (using VBScript), use the following code:</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">The following code loads an existing XML document ("note.xml") into Microsoft's XML parser:</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;"><script type="text/javascript"></span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">xmlDoc.async="false"</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">xmlDoc.load("note.xml")</span> </div><div style="color: #7f6000;"><span style="font-weight: bold;">...</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">...</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;">...</span> </div><div style="color: #7f6000;"><br />
</div><div style="color: #7f6000;"><span style="font-weight: bold;"></script></span> </div>kejalhttp://www.blogger.com/profile/07909335658390396159noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-17576090750659129452009-10-13T01:46:00.000-07:002010-10-11T01:11:43.664-07:00Xml Parser in Mozilla Browsers<div style="color: #0c343d;"><span style="font-weight: bold;">Plain XML documents are displayed in a tree-like structure in Mozilla (just like IE).<br />
<br />
Mozilla also supports parsing of XML data using Javascript. The parsed data can be displayed as HTML.<br />
<br />
To create an instance of the XML parser with JavaScript in Mozilla browsers, use the following code:<br />
<br />
var xmlDoc=document.Implementation.createDocument("ns", "root", null)<br />
<br />
The first parameter, ns, defines the name space used for the XML document. The second parameter, root, is the XML root element in the XML file. The third parameter, null is always null because it is not implemented yet.<br />
<br />
The following code loads an existing XML document ("note.xml") into Mozillas' XML parser.<br />
<br />
<script type="text/javascript"><br />
var xmlDoc=document.implementation.createDocument("", "",null);<br />
xmlDoc.load("note.xml");<br />
. . .<br />
. . .<br />
<br />
</script><br />
<br />
The first line of the script above creates an instance of the XML parser. The second line tells the parser to load an XML document called "note.xml".</span></div>kejalhttp://www.blogger.com/profile/07909335658390396159noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-4772642678003413462009-08-24T06:26:00.000-07:002009-08-24T06:29:09.237-07:00Loading an XMl File - A cross browser example<span style="font-weight: bold; color: rgb(255, 102, 0);">The following example is a cross browser example that loads an existing XML document ("note.xml") into the XML browser</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><html></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><head></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><script type="text/javascript"></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">function LoadXML( )</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">{</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">// load xml file</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">//code for IE</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">if (window.ActiveXObject)</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">{</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc=new ActiveXObject("Mircosoft.XMLDOM")L</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.async=false;</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.load("note.xml");</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">getmessage( )</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">// code for Mozilla, etc</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">else if (documet.implementation && document.implementation.createDocument("","",null);</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.load ("note.xml")</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.onload = get message</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">}</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">else</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">{</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">alert ('Your browser cannot handle this script');</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"> }</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">}</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">function getmessage( )</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">{</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">document.getElementById("to").innerHTML=</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.getElementsByTagNAme("to")[0].firstChild.nodeValue</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">document.getElementsById("from").innerHTML=</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.getElementsById("message").innerHTML=</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.getElementsByTagName("body")[0].firstChild.nodeValue</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">}</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></script></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></head></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><body onLoad="loadXML( )" bgcolor="yellow")</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><h1>MHIIT Internal Note </h1></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><p><b>To:</b> <span id="from"> </span></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><hr /></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><b> Message: </b> <span id="message"> </span></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></p></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></body></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></html></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-17432698242604599992009-08-24T06:25:00.000-07:002009-08-24T06:26:23.048-07:00Loading XML Text into the Browser<span style="font-weight: bold; color: rgb(255, 102, 0);">Internet Explorer supports two ways of loading XML into a document object: the load( )</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">method and the loadXML( ) method. The load( ) method loads an XML file and the loadXML( ) method loads a text string that contains XML code.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">The following code loads that a text string into Microsoft's XML parser:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><script type="text/javascript"></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">var txt= "<note>"</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">var = txt + "<to>Rasik</to><from>Bapotra<from>"</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">txt = txt + "<heading>Reminder</heading>"</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">txt = txt + "<body>Don't forget me this weekend!</body>"</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">txt = txt + "</note>"</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">var xmldoc=new ActiveXObject("Microsoft.XMLDOM")</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.async= "false"</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"> xmlDoc.loadXML(txt)</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">document.write("The first child elment in the txt contains: " + </span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.documentElement.childNodes(0).text)</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">document.write(" br / >" )</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">document.write("The second child element in the text contains: " +</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.documentElement.childNodes(1).text)</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></script></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></body></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></html></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-49529386335461214232009-08-06T10:00:00.000-07:002009-08-19T07:01:49.324-07:00XML Embedded in HTML<span style="font-weight: bold; color: rgb(255, 102, 0);">Xml in Data Islands.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">With Internet Explorer, XML can be embedded into HTML pages in Data Islands.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">XML Embedded in HTML</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">The unofficial <xml> tag is used to embed XML data within HTML.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">XML data can be embedded directly into an HML page like this:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><xml id="note"></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><note></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><to> Rasik</to></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><from>Bapora</from></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><heading>Reminder</heading></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><body>Dont't forget me this weekend!</body></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></note></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></xml></span><br /><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">An an external XML file can be embedded like this:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><xml id="note" src="note.xml"></span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></xml></span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Note: The <xml> tag is an HTML element, not an XML element.</span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-87350557919074258732009-08-05T09:02:00.000-07:002009-08-19T07:04:47.680-07:00XML Parser<span style="font-weight: bold; color: rgb(255, 102, 0);">To read and update - create and manipulate - an XML document, you will need an XML parser, </span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Microsoft' s XML Parser</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Microsoft's XML parser is a COM component that comes with internet explorer 5 and higher. Once you have installed Internet Explorer, the parser is available to scripts.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Microsoft's XML parser supports all the necessary functions to traverse the node tree, access the nodes and their attribute values, insert and delete nodes, and convert the node tree back to XML.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">The following table lists the most commonly used node types supported by Microsoft's XML parser:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Node Type Example</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Processing Instruction <?xml version="1.0"?></span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Element <drink type="beer"&</span><span style="font-weight: bold; color: rgb(255, 102, 0);">gt;Carlsberg</drink></span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Attribute type="beer"</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Text Carlsberg</span><br /><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">MSXML Parser 2.5 is the XML parser that is shipped with windows 2000 and IE 5.5.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">MSXML Parser 3.0 is the XML parser that is shipped with IE 6.0 and Windows XP.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">The MSXML 3.0 parser features:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Javascript, VBScript, Perl, VB, Java, C++, etc. support</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Complete XML Support</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Full DOM and Namespace support</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">DTD and validation</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Complete XSLT and XPATH support</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">SAX2 support</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Server-safe HTTP</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">TO Create an instance of Microsoft's XML parser with Javascript, use the following code:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">---------------------------------------------------------------------------------------------------------------------------------------------</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">--------------------------------------------------------------------------------------------------------------------------------------------</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">To create an instance of Microsoft's XML parser with VBScript, use the following code</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">------------------------------------------------------------------------------------</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">set xmlDoc=CreateObject("Microsoft.XMLDOM")</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">------------------------------------------------------------------------------------</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">To create an instance of Microsoft's XML parser in an ASP Page (using VBScript), use the following code:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">the following code loads an existing XML document ("note.xml") into Microsoft's XML parser:</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><script type ="text/javascript"></span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.async="false"</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">xmlDoc.load("note.xml")</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">.....</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">.....</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">.....</span><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"></script></span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">The first line of the script above creates an instance of the Microsoft XML parser. The third line tells the parser to load an XML document called "note.xml". The second line turns off asynchronised loading, to make sure that the parser will not continue execution of the script before the document is fully loaded.</span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-59653344060565325432009-08-04T11:15:00.000-07:002009-08-19T06:58:52.738-07:00Data Binding<span style="font-weight: bold; color: rgb(255, 102, 0);">Data Binding</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">XML Data Islands can be bound to HTML elements.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">In the example below, an XML Data with an ID OF "cdcat" is loaded from tan extreme XML file ("cd_catalog.xml"). Next, the HTML table </span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">element is bound to the Data Island with the datasrc attribute, and finally the td elements are bound to the XML data with a datafld attribute </span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">inside a span element.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><html><br /><body><br /><br /><xml id="cdcat" src="cd_catalog.xml"></xml><br /><br /><table border="1" datasrc="#cdcat"><br /><tr><br /><td><span datafld="ARTIST"></span></td><br /><td><span datafld="TITLE"></span></td><br /></tr><br /></table><br /><br /></body><br /></html></span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);">Also try following tutorial, demonstrating <thead>, <tbody>, and <tfoot>.</span><br /><br /><span style="font-weight: bold; color: rgb(255, 102, 0);"><html><br /><body><br /><xml id="cdcat" src="cd_catalog.xml"></xml><br /><table border="1" datasrc="#cdcat"><br /><thead><br /><tr<th>Artist</th>Title</th></tr><br /></thead><br /><tfoot><br /><tr><th colspan="2">This is my CD collection</th></tr><br /></tfoot><br /><tbody><br /><tr><br /><td><span datafld="artist"></span></td><br /><td><span datafld="title"></span></td><br /></tr><br /></tbody><br /></table><br /></body><br /></html></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-25145554262067469222009-05-06T01:57:00.000-07:002009-05-06T01:59:26.831-07:00XML DTD<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><br />A DTD defines the legal elements of an XML document.<br /><br />The purpose of a DTD is to define the legal building blocks of an XML document.it defines the document with a list of legal elements.<br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-20573797424945395472009-05-06T01:50:00.000-07:002009-05-06T01:56:14.411-07:00Valid XML documents<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"> A "Valid" XML document also confirms to a DTD.<br /><br />A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD)<br /><br /><span style="color: rgb(51, 204, 0);"><?xml version="1.0" encoding="ISO-8859-1"?><br /><!DOCTYPE note SYSTEM "InternalNote.dtd"><br /><note><br /><to>Rasik</to><br /><from>Bapotra</from><br /><heading>Reminder</heading><br /><body>Don't forget me this weekend!</body><br /></note></span><span style="color: rgb(51, 204, 0);"></span><br /><br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-40499077872452024082009-05-06T01:36:00.000-07:002009-05-06T01:41:25.988-07:00XML Validation<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">XML with correct syntax is Well Formed XML.<br /><br />XML validated against a DTD is Valid XML<br /><br />"Well Formed" XML documents<br /><br />A "Well Formed" XML document has correct XML syntax.<br /><br />A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous characters:<br /><br /><span style="color: rgb(51, 204, 0);"><?xml version="1.0" encoding="ISO-8859-1"?><br /><note><br /><to>Rasik</to><br /><from>Bapotra</from><br /><heading>Reminder</heading><br /><body>Don't forget me this weekend!</body><br /></note></span><span style="color: rgb(51, 204, 0);"></span><br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-87909860390121596042009-05-06T01:23:00.000-07:002009-05-06T01:35:07.202-07:00Avoid using Attributes?<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">Should you avoid using attributes?<br /><br />Some of the problems with using attributes are:<br /><br /></span></span><ul><li><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);">attributes cannot contain multiple values (<span style="color: rgb(255, 102, 0);">child elments can</span>)</span></span></span></li><li><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);">attributes are not easily expandable (<span style="color: rgb(255, 102, 0);">for future changes</span>)</span></span></span></li><li><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);">attributes cannot describe structures (<span style="color: rgb(255, 102, 0);">child elements can</span>)</span></span></span></li><li><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);">attributes are more difficult to manipulate by program code.</span></span></span></li><li><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);">attribute values are not easy to test against a Document Type Definition (<span style="color: rgb(255, 102, 0);">dtd</span>) - which is used to define the legal elements of an XML document.</span></span></span></li></ul><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);"><br /><span style="color: rgb(255, 102, 0);">If you use attributes as containers for data, you end up with documents that are difficult to read and maintain. Try to use <span style="color: rgb(51, 204, 0);">elements <span style="color: rgb(255, 102, 0);">to describe data. Use attributes only to provide information that is not relevant to the data.<br /><br /><br />Don't end up like this ( this is not how XML should be used ):<br /><br /><span style="color: rgb(51, 255, 255);">--------------------------------------------------------------------------------------------</span><br /><span style="color: rgb(51, 204, 0);"><note day="12" month="11" year="2002"><br />to="Rasik" from="Bapotra" heading="Remember" body="Don 't forget me this weekend!"><br /></note></span><span style="color: rgb(51, 204, 0);"></span><br /><span style="color: rgb(102, 255, 255);">--------------------------------------------------------------------------------------------</span></span></span></span><br /></span></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-14286635330482370912009-05-06T01:08:00.000-07:002009-05-06T01:22:49.089-07:00store data in child elements<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">the following three xml documents contain exactly the same information.<br /><br />A date attribute is used in first tutorial.<br /><br /><span style="color: rgb(51, 204, 0);"><note date="12/11/2002"></span><br /><span style="color: rgb(51, 204, 0);"><to><span style="color: rgb(255, 102, 0);">Rasik</span></to></span><br /><span style="color: rgb(51, 204, 0);"><from><span style="color: rgb(255, 102, 0);">Bapotra</span></from></span><br /><span style="color: rgb(51, 204, 0);"><heading><span style="color: rgb(255, 102, 0);">Reminder</span></heading></span><br /><span style="color: rgb(51, 204, 0);"><body><span style="color: rgb(255, 102, 0);">Dont't forget me this weekend!</span></body></span><br /><span style="color: rgb(51, 204, 0);"></note></span><br /><br />A date element is used in the second tutorial.<br /><br /><span style="color: rgb(51, 204, 0);"><note date="<span style="color: rgb(255, 102, 0);">12/11/2002</span>"><br /><to><span style="color: rgb(255, 102, 0);">Rasik</span></to><br /><from><span style="color: rgb(255, 102, 0);">Bapotra</span></from><br /><heading><span style="color: rgb(255, 102, 0);">Reminder</span></heading><br /><body><span style="color: rgb(255, 102, 0);">Dont't forget me this weekend!</span></body><br /></note></span></span></span><span style="color: rgb(255, 102, 0);"><br /><br /></span><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">An expanded date element is used in the third tutorial<br /><br /><span style="color: rgb(51, 204, 0);"><note><br /><date><br /><day><span style="color: rgb(255, 102, 0);">12</span></day><br /><month><span style="color: rgb(255, 102, 0);">11</span></month><br /><year><span style="color: rgb(255, 102, 0);">2002</span></year><br /></<span style="color: rgb(255, 102, 0);">date</span>><br /><to><span style="color: rgb(255, 102, 0);">Rasik</span></to><br /><from><span style="color: rgb(255, 102, 0);">Bapotra</span></from><br /><heading><span style="color: rgb(255, 102, 0);">Reminder</span></heading><br /><body><span style="color: rgb(255, 102, 0);">Don't forget me this weekend!</span></body><br /></note></span></span></span><br /><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-51409829619338004192009-05-06T00:57:00.000-07:002009-05-06T01:08:11.928-07:00Use of Elements vs Attributes<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">Data can be stored in child elements or in attributes.<br /><br />Take a look at this tutorials.<br /><br /><span style="color: rgb(51, 204, 0);"><person sex="female"></person></span></span></span><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);"><person sex="female"></span><br /><span style="color: rgb(51, 204, 0);"><firstname>Anna</firstname></span><br /><span style="color: rgb(51, 204, 0);"><lastname>smith</lastname></span><br /><span style="color: rgb(51, 204, 0);"></person></span><br /><br /><span style="color: rgb(255, 255, 51);">--------------------------------------------------------------------------------------------------</span><br /><span style="color: rgb(255, 255, 51);">--------------------------------------------------------------------------------------------------</span><br /><br /><span style="color: rgb(51, 204, 0);"><person></span><br /><span style="color: rgb(51, 204, 0);"><sex>Female</sex></span><br /><span style="color: rgb(51, 204, 0);"><lastname>smith</lastname></span><br /><span style="color: rgb(51, 204, 0);"></person></span><br /><br /></span></span><br /><span style="color: rgb(255, 102, 0);"><span style="color: rgb(102, 255, 255);"><span style="color: rgb(255, 102, 0);"></span><br /><span style="font-weight: bold;"><span style="color: rgb(255, 102, 0);"><br />In the first tutorial sex is an attribute. In the last sex, is a child element.Both examples provide the same information.<br /><br />There are no rules about when to use attributes, and when to use child elements. My experience is that attributes are handy in HTML, but in XML you should try to avoid them. Use child elements if the information feels like data.<br /></span></span><br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-12256612828184243292009-04-19T04:04:00.000-07:002009-04-19T04:25:25.713-07:00DATA BINDING<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">xml data isalands can be bound to HTML elements<br /><br />In the example below, an XML Data Island with an ID of "cdcat" is loaded from an extreme XML file ("cd_catalog.xml").Next, the HTML table element is bound to the Data Island with the datasrc attribute, and finally the td elements are bound to the XML data with a datafld attribute inside a span element<br /><br /><br /><span style="color: rgb(51, 204, 0);"><html></span><br /><span style="color: rgb(51, 204, 0);"><body></span><br /><span style="color: rgb(51, 204, 0);"><xml id ="cdcat" src="cd_catalog.xml"></xml></span><br /><span style="color: rgb(51, 204, 0);"><table border="1" datasrc="#cdcat"></span><br /><span style="color: rgb(51, 204, 0);"><thread></span><br /><span style="color: rgb(51, 204, 0);"><tr><th>Artist</th><th><Title</th></tr></span><br /><span style="color: rgb(51, 204, 0);"></thread></span><br /><span style="color: rgb(51, 204, 0);"><tfoot></span><br /><span style="color: rgb(51, 204, 0);"><tr></span><br /><span style="color: rgb(51, 204, 0);"><th colspan\"2">This is my CD collection </th></tr></span><br /><span style="color: rgb(51, 204, 0);"></tfoot></span><br /><span style="color: rgb(51, 204, 0);"><tbody></span><br /><span style="color: rgb(51, 204, 0);"><tr></span><br /><span style="color: rgb(51, 204, 0);"><td><span datafld="artist"></span></td></span><br /><span style="color: rgb(51, 204, 0);"><td><span datafld="title"></span></td></span><br /><span style="color: rgb(51, 204, 0);"></tr></span><br /><span style="color: rgb(51, 204, 0);"></tbody></span><br /><span style="color: rgb(51, 204, 0);"></table></span><br /><span style="color: rgb(51, 204, 0);"></body></span><br /><span style="color: rgb(51, 204, 0);"></html></span><br /><br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-29212255422958718362009-04-19T03:13:00.000-07:002009-04-19T03:26:56.308-07:00DISPLAYING XML WITH XSL<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">XSL is the preffered style sheet language of XML.<br /><br />XSL (the extensible Stylesheet Language) is afr more sophisticated than CSS.One way to use xsl is to transform XML into HTML before it is diplayed by the browser as demonstrated in these examples.<br /><br />Below is a fraction of the XML file.The second line, , links the XML file to the XSL file:<br /><br />Simple.xml<br /><span style="color: rgb(51, 204, 0);"><?xml version="1.0" encoding="ISO-8859-1" ?></span><br /><br /><span style="color: rgb(51, 204, 0);"><breaskfast_menu></span><br /><span style="color: rgb(51, 204, 0);"><food></span><br /><span style="color: rgb(51, 204, 0);"><name>Belgian Waffles</name></span><br /><span style="color: rgb(51, 204, 0);"><price>$6.95</price></span><br /><span style="color: rgb(51, 204, 0);"><description>two of our famous Belgian Waffles with plenty of real sample syrup</description></span><br /><span style="color: rgb(51, 204, 0);"><calories>650</calories></span><br /><span style="color: rgb(51, 204, 0);"></food></span><br /><span style="color: rgb(51, 204, 0);"><food></span><br /><span style="color: rgb(51, 204, 0);"><name>Sample Waffles</name></span><br /><span style="color: rgb(51, 204, 0);"><price>$7.95</price></span><br /><span style="color: rgb(51, 204, 0);"><description>light Belgian waffles covered with strawberries and whipped cream</description></span><br /><span style="color: rgb(51, 204, 0);"><calories>900</calories></span><br /><span style="color: rgb(51, 204, 0);"></food></span><br /><span style="color: rgb(51, 204, 0);"><food></span><br /><span style="color: rgb(51, 204, 0);"><name>Berry-Berry Belgian Waffles</name></span><br /><span style="color: rgb(51, 204, 0);"><price>$8.95</price></span><br /><span style="color: rgb(51, 204, 0);"><description>light Belgian waffles covered withan assortment of fresh berries and whipped cream</description></span><br /><span style="color: rgb(51, 204, 0);"><calories>900</calories></span><br /><span style="color: rgb(51, 204, 0);"></food></span><br /><span style="color: rgb(51, 204, 0);"><food></span><br /><span style="color: rgb(51, 204, 0);"><name>French Toast</name></span><br /><span style="color: rgb(51, 204, 0);"><price>$4.50</price></span><br /><span style="color: rgb(51, 204, 0);"><description>thick slices made from our homemade sourdough bread</description></span><br /><span style="color: rgb(51, 204, 0);"><calories>600</calories></span><br /><span style="color: rgb(51, 204, 0);"></food></span><br /><span style="color: rgb(51, 204, 0);"><food></span><br /><span style="color: rgb(51, 204, 0);"><name>Homestyle Breakfast</name></span><br /><span style="color: rgb(51, 204, 0);"><price>$6.95</price></span><br /><span style="color: rgb(51, 204, 0);"><description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description></span><br /><span style="color: rgb(51, 204, 0);"><calories>950</calories></span><br /><span style="color: rgb(51, 204, 0);"></food></span><br /><span style="color: rgb(51, 204, 0);"></breakast_menu></span><br /><br /><span style="color: rgb(51, 204, 0);">simple.xsl<br /><?xml version="1.0" encoding="ISO-8859-1"?><br /><html xsl:version="1.0' xmlns:xsl= "http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"><br /><body style="font-family:Arial,helvetica,sans-serif;font-size:12pt; background-color:#EEEEEE"><br /><xsl.for-each select= "breakfast_menu/food"><br /><div style="background-color:teal;apdding:4px"><br /><span style="font-weight:bold;"><br /><xsl:value-of select="name"/><br /></span><br /><br /><xsl:value-of select="price" /><br /></div><br /><div style="margin-left:20px;margin-bottom:1em;font-size:10pt"><br /><xsl:value-of select="description" /><br /><span style="font-style:Italic"><br />(<br /><xsl:value-of select="calories" /><br />(calories per serving)<br /></span><br /></div><br /></xsl:for-each><br /></body><br /></html><br /><br /><br /></span><br /><br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com1tag:blogger.com,1999:blog-3390997972526934192.post-72653653873849836812009-04-19T01:51:00.000-07:002009-04-19T02:57:47.769-07:00Displaying XML Files with CSS<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">Displaying XML Files with<br /><br /><span style="color: rgb(51, 204, 0);">With CSS (Cascading Style Sheets) you can add display information to an XML document.<br /><br />It is possible to use CSS to format an XML document.<br /><br />Below is an Tutorial of how to use a CSS style sheet to format an XML document:<br /><br />Take a look at this XML file:<br /><br />Cd_catalog.xml<br /><br /><br /><?xml version="1.0" encoding="ISO-8859-1" ?><br /><!--<br />--><br /><CATALOG><br /><CD><br /><TITLE>Empire Builders</TITLE><br /><ARTIST>Bob Dylan</ARTIST><br /><COUNTRY>USA</COUNTRY><br /><COMPANY>Columbia</COMPANY><br /><PRICE>10.90</PRICE><br /><YEAR>1985</YEAR><br /></CD><br /><CD><br /><TITLE>New Era Co</TITLE><br /><ARTIST>John Dyke</ARTIST><br /><COUNTRY>UK</COUNTRY><br /><COMPANY>CBS Records</COMPANY><br /><PRICE>9.90</PRICE><br /><YEAR>1988</YEAR><br /></CD><br /><CD><br /><TITLE>Greatest Hits</TITLE><br /><ARTIST>Doll7y Parton</ARTIST><br /><COUNTRY>USA</COUNTRY><br /><COMPANY>RCA</COMPANY><br /><PRICE>9.90</PRICE><br /><YEAR>1982</YEAR><br /></CD><br /></CATALOG><br /><br /><br />Then look at this stylesheet<br /><br />CATALOG<br />{<br />background-color: #ffffff;<br />width: 100%;<br />}<br />CD<br />{<br />display: block;<br />margin-bottom: 30pt;<br />margin-left: 0;<br />}<br />TITLE<br />{<br />color: #FF0000;<br />font-size: 20pt;<br />}<br />ARTIST<br />{<br />color: #0000FFl<br />font-size: 20pt;<br />}<br />COUNTRY,PRICE,YEAR,COMPANY<br />{<br />display: block;<br />color: #000000<br />margin-left: 20pt;<br />}<br /><br />Then look at this stylesheet<br /><br />CATALOG<br />{<br />background-color: #ffffff;<br />width: 100%;<br />}<br />CD<br />{<br />display: block;<br />margin-bottom: 30pt;<br />margin-left: 0;<br />}<br />TITLE<br />{<br />color: #FF0000;<br />font-size: 20pt;<br />}<br />ARTIST<br />{<br />color: #0000FFl<br />font-size: 20pt;<br />}<br />COUNTRY,PRICE,YEAR,COMPANY<br />{<br />display: block;<br />color: #000000<br />margin-left: 20pt;<br />}<br /><br /><br />Finally, view the output<br /><br />Below is a fraction of the XML file.The second line, <?xml-stylesheet type="text/css" href="cd_catalog.css"?>, links the XML file to the CSS file:<br /><br /><br /><?xml version="1.0" encoding="ISO-8859-1"?><br /><?xml-stylesheet type="text/css" href= "cd_catalog.css"?><br /><CATALOG><br /><CD><br /><TITLE>Wwe empires</TITLE><br /><ARTIST>John</ARTIST><br /><COUNTRY>UK</COUNTRY><br /><COMPANY>Columbia</COMPANY><br /><PRICE>10.90</PRICE><br /><YEAR>1985</YEAR><br /></CD><br /><CD><br /><TITLE>Empire Builders</TITLE><br /><ARTIST>Bob Dylan</ARTIST><br /><COUNTRY>USA</COUNTRY><br /><COMPANY>Columbia</COMPANY><br /><PRICE>10.90</PRICE><br /><YEAR>1985</YEAR><br /></CD><br /></CATALOG><br /><br /><br /><div class="codeview"><catalog><cd><br /></cd></catalog></div></span></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-10062497221914348662009-04-19T01:22:00.000-07:002009-04-19T01:46:52.861-07:00Viewing XML files in Firefox and Internet Explorer:<span style="font-weight: bold; color: rgb(255, 102, 0);">In Firefox and Internet Explorer</span><br /><br /><span style="color: rgb(51, 204, 0);"><span style="font-weight: bold;">Open t</span>he <span style="font-weight: bold;">XML files (typically by clicking on a link) - the XML document will be displayed with color-coded root and child elements.Aplus (+) or minus sign (-) to the left of the elements can be clicked to expand or collapse the element structure.To view the raw XML source (without the + and - signs), select "View Page Source" from the browser menu.<br /><br /><span style="color: rgb(255, 102, 0);">A Simple Food Menu</span><br />This is a breakfast food menu from a restaurant, stored as XML data.<br /><?xml version="1.0" encoding="ISO-8859-1" ?><br /><br /><breaskfast_menu><br /><food><br /><name>Belgian Waffles</name><br /><price>$6.95</price><br /><description>two of our famous Belgian Waffles with plenty of real sample syrup</description><br /><calories>650</calories><br /></food><br /><food><br /><name>Sample Waffles</name><br /><price>$7.95</price><br /><description>light Belgian waffles covered with strawberries and whipped cream</description><br /><calories>900</calories><br /></food><br /><food><br /><name>Berry-Berry Belgian Waffles</name><br /><price>$8.95</price><br /><description>light Belgian waffles covered withan assortment of fresh berries and whipped cream</description><br /><calories>900</calories><br /></food><br /><food><br /><name>French Toast</name><br /><price>$4.50</price><br /><description>thick slices made from our homemade sourdough bread</description><br /><calories>600</calories><br /></food><br /><food><br /><name>Homestyle Breakfast</name><br /><price>$6.95</price><br /><description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description><br /><calories>950</calories><br /></food><br /></breakast_menu><br /><br /><br /><div class="codeview"><br /><?xml version="1.0" encoding="ISO-8859-1" ?><br /><br /><breaskfast_menu><br /><food><br /><name>Belgian Waffles</name><br /><price>$6.95</price><br /><description>two of our famous Belgian Waffles with plenty of real sample syrup</description><br /><calories>650</calories><br /></food><br /><food><br /><name>Sample Waffles</name><br /><price>$7.95</price><br /><description>light Belgian waffles covered with strawberries and whipped cream</description><br /><calories>900</calories><br /></food><br /><food><br /><name>Berry-Berry Belgian Waffles</name><br /><price>$8.95</price><br /><description>light Belgian waffles covered withan assortment of fresh berries and whipped cream</description><br /><calories>900</calories><br /></food><br /><food><br /><name>French Toast</name><br /><price>$4.50</price><br /><description>thick slices made from our homemade sourdough bread</description><br /><calories>600</calories><br /></food><br /><food><br /><name>Homestyle Breakfast</name><br /><price>$6.95</price><br /><description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description><br /><calories>950</calories><br /></food><br /></breakast_menu><br /></div><br /><br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-36188286146561213542009-04-18T05:24:00.000-07:002009-04-19T01:24:56.007-07:00Errors will Stop you in XML<span style="color: rgb(51, 204, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 102, 255);">ERRORS IN XML Documents will stop the XML program.</span><br /><br />The W3C XML specification states that a program should not continue to process an XML document if it finds a syntax error.The reason is that XML software should be easy to write, and that all XML documents should be compatible.<br /><br />With HTML it was possible to create that documents with lots of errors (like when you forget an end tag). One of the main reasons that HTML browsers are so big and incompatible, is that they have their own ways to figure out what a document should look like when they encounter an HTML error.<br /><br />With XML this should not be possible.<br /><br />Viewing XML Files<br /><br />Raw xml files can be viewed in Mozilla,FireFox, Opera, Internet Explorer, and in Netscape 6+.<br /><br />However, to make XML documents to display like nice web pages, you will have to add some display information.<br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-65868994306963512792009-04-18T05:10:00.000-07:002009-04-18T05:21:50.392-07:00Valid XML Documents<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">A "Valid" XML document also conforms to a DTD
<br />
<br /><span style="color: rgb(51, 204, 0);">A "Valid" XML document is a "Well Formed' XML document, which also conforms to the rules of a Document Type Definition (DTD):
<br />
<br /><?xml version="1.0" encoding="ISO-8859-1"?>
<br /><!DOCTYPE note SYSTEM "InternalNote.dtd">
<br /><note>
<br /><to>abcd</note>
<br /><from>welcome to my site</from>
<br /><heading>Reminder</heading>
<br /><body>Don't forget me this weekend!</body>
<br /></note>
<br />
<br /></span></span></span><span style="font-weight: bold; color: rgb(51, 204, 0);"><div class="codeview"></span>
<br /><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);"><?xml version="1.0" encoding="ISO-8859-1"?>
<br /><!DOCTYPE note SYSTEM "InternalNote.dtd">
<br /><note>
<br /><to>abcd</note>
<br /><from>welcome to my site</from>
<br /><heading>Reminder</heading>
<br /><body>Don't forget me this weekend!</body>
<br /></note>
<br /></span></span></span><span style="font-weight: bold; color: rgb(51, 204, 0);"></div></span>
<br /><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><span style="color: rgb(51, 204, 0);">
<br /></span></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0tag:blogger.com,1999:blog-3390997972526934192.post-15266677180928522332009-04-18T04:52:00.000-07:002009-04-18T05:09:57.314-07:00Avoid Using Attributes<span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;">should you avoid using attributes?<br /><br />Some of the problems with using attributes are:<br /><br /><span style="color: rgb(51, 204, 0);">attributes cannot contain multiple values (child elements can)</span><br /><br /><span style="color: rgb(51, 204, 0);">attributes are not easily expandable (for future changes)<br /><br />attributes cannot describe structures (child elements can)<br /><br />attributes are more difficult to manipulate by program code<br /><br />attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document.<br /><br />If you use attributes as containers for data, you end up with documents that difficult to read and maintain.Try to use <span style="color: rgb(51, 102, 255);">elements</span> to describe data.Use attributes only to provide information that is not relevant to the data.<br /><br />Don't end up like this (this is not how xml should be used):<br /><note day="12" month="11" year="2002" to ="Rasik" from="Bapotra"<br />heading="Remember" body="Dont forget me this weekend!"><br /></note><br /><br /><br /></span></span></span><span style="color: rgb(255, 102, 0);"><span style="font-weight: bold;"><br /></span></span>rajhttp://www.blogger.com/profile/07775159902177850551noreply@blogger.com0