| Well-Formed XML Documents If an XML document is not understood successfully by an XML processor then the processor cannot format the document. To handle that, XML documents are subject to two constraints: well formedness and validity, well formedness being the basic constraint. Well-Formed Document As set by the W3C, for an XML document to be well formed it should follow the document production containing three parts in the document.
The prolog should include an XML declaration such as <?xml version="1.0"?>. It can also contain a Document Type Definition (DTD). The root element of a document can hold other elements and the document should contain exactly one root element. All other elements should be enclosed within the root element. The optional miscellaneous part can be made up of XML comments, processing instructions and whitespaces. Also the XML document should follow the syntax rules specified in the XML 1.0 recommendation set by W3C. An example of a well formed document is listed below :
Understanding the above document for well-formedness: Data can be stored for as many consumers as wanted and handling such kind of data is not a problem for the XML processor. The following are the basic rules that should be kept on mind when creating a Well-Formed XML document.
Documents like the one above can be extended as long as we can. XML doesn't have any problem handling such kind of documents, as long as they are wellformed. | ||
Valid XML Documents An XML document is said to be valid if it has a Document Type Definition (DTD) or XML schema associated with it and if the document complies with it. DTD's are all about specifying the structure of the document and not the content of the document. And with a common DTD many XML applications can be shared. Such is the importance of a DTD. Let's take a look at the example which was created in the section Well-Formed XML documents.
Adding a DTD to the example above makes the code look like this:
Breaking the DTD for understanding: That's how a basic DTD looks like. A DTD like the one above is said to be an internal DTD. We can also create external DTD's and it's these external DTD's which allows us to share a common XML document within different organizations. For more information about how to insert attributes, comments, etc in DTD's please refer to the W3C specification for XML DTD's. The image below shows how the above code when opened in an browser looks like. |
WIDE COLLECTION OF DOTNET TUTORIALS AND MCA STUDENTS JOB OPENINGS/INTERVIEW QUESTONS ......MUCH MORE
Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts
Tuesday, July 19, 2011
XML SAMPLE CODE
XML WEBSERVICES
Subscribe to:
Posts (Atom)