|
Source Code : XML for Beginners
Introduction License The Extensible Markup Language (XML) is a general-purpose markup language. It is classified as an extensible language because it allows its users to define their own tags. In Software Engineering, extensible refers to the system that can be modified by changing or adding features. Its primary purpose is to facilitate the sharing of data across different information systems, particularly via the Internet. XML is recommended by the World Wide Web Consortium (W3C). It is a fee-free open standard. The W3C recommendation specifies both the lexical grammar, and the requirements for parsing. The basic difference between HTML and XML is:
A well formed XML must have proper opening and closing tags. Data can be stored in child elements or in attributes, e.g.: Attributes are handy in HTML, but in XML, it is better to avoid them. Use child elements if the information feels like data. XML ValidationThere are two levels of correctness of an XML document:
A Well Formed XML document is a document that conforms to the XML syntax rules like:
A Valid XML document is a "Well Formed" XML document, which conforms to the rules of a Document Type Definition (DTD). Document Type Definition (DTD)The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. A DTD can be declared inline inside an XML document, or as an external reference. If the DTD is declared inside the XML file, it should be wrapped in a DOCTYPE definition with the following syntax: The DTD above is interpreted like this:
If the DTD is declared in an external file, it should be wrapped in a DOCTYPE definition with the following syntax: And this is the file note.dtd which contains the DTD: XML Schema is used to define the legal building blocks of an XML document, just like a DTD. XML Schemas are the successors of DTDs and also referred to as XML Schema Definition (XSD). XML Schemas are now used in most Web applications as a replacement for DTDs and in the near future, they will completely replace DTDs due to the following reasons:
An example of a very simple XML Schema Definition to describe a country is given below: An example of an XML document that confirms to this schema is given below (assuming the schema file name is country.xsdand both files are in the same directory): The best way to explain XQuery is to say that: "XQuery is to XML what SQL is to database tables" XQuery was designed to query XML data. XQuery is also known as XML Query. The mission of the XML Query project is to provide flexible query facilities to extract data from real and virtual documents on the World Wide Web, therefore finally providing the needed interaction between the Web world and the database world. Ultimately, collections of XML files will be accessed like databases. XQuery uses XPath (XPath is a language for finding information in an XML document. XPath is used to navigate through elements and attributes in an XML document.) expression syntax to address specific parts of an XML document. It supplements this with a SQL-like "FLWOR expression" for performing joins. A FLWOR expression is constructed from the five clauses after which it is named: FOR, LET, WHERE, ORDER BY, RETURN. ExampleLet's take any XML document: A simple XQuery can be written to extract a record out of this XML document like: The XQuery above will extract the following: XML document can be validated against XML schema (XSD). XSD checks the XML document's complete structure and reports an error if any datatype mismatches or node element does not exist. Below is sample code written in C# which takes an XML document and an XSD document as input and validates the XML document: This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Comments
|
Recent Posts
The XmlTextReader - A Beginner's Guide
Creating XML and Java Technology Based Application Source Code : XML for Beginners Source code : JavaScript For Beginners Top 5 ways to save on car insurance SQL Server : The Most Powerful DBA Tool How to Spend Your Credit Card Cash Back Money Types Of Hair Loss Treatment Available To Sufferer 5 Things You Must Have Succeeding in Affiliate Mar How To Get A Six Pack - Calling All Couch Potatoes Syndication Tools |
|
You are not logged in. FREE Sign Up or Log In
©2009 Flixya Entertainment, LLC. All rights reserved.




Free Sign Up - Start Making Money on Flixya »




-------------------