XML
  Home arrow XML arrow Page 4 - XML Basics
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

XML Basics
By: Mamun Zaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 19
    2007-09-05

    Table of Contents:
  • XML Basics
  • XML Tags and Conventions
  • More on Elements
  • XML Schema

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    XML Basics - XML Schema


    (Page 4 of 4 )

    XML Schema is an XML-based alternative to DTD. An XML Schema describes the structure of an XML document. The XML Schema language is also referred to as XML Schema Definition (XSD). An XML Schema defines the following:

    • Elements and attributes that can appear in a document.
    • Child elements.
    • The order and number of child elements.
    • Whether an element is empty or can include text.
    • Data types for elements and attributes.
    • Default and fixed values for elements and attributes.

    The schema element is the first element in an XML schema file. The prefix xsd: is used to indicate the XML schema namespace:

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     

    </xsd:schema>

    The main sub-elements in an XML schema document are:

    1. element – declares an element.
    2. attribute – declares an attribute.
    3. complexType – defines elements that can contain other elements and attributes.
    4. simpleType – defines elements that can not contain other elements or attributes. These elements are of basic types, including string, date, integer etc.

    The xsd:annotation and xsd:documentation tags are used for providing a description of the document. Here is an example:

    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <xsd:annotation>
          <xsd:documentation xml:lang="en">
                Bookstore schema for book.xml
          </xsd:documentation>
      </xsd:annotation>
    </xsd:schema>

     

    In our XML example the element bookstore is a complexType element because it contains book sub-elements.

    <xsd:element name="bookstore" type="bookstoreinfo"/>

    <xsd:complexType name="bookstoreinfo">
          <xsd:sequence>
                <xsd:element name="book" type="bookinfo"/>
          </xsd:sequence>
    </xsd:complexType>

    Our book element is also a complexType element.

    <xsd:compleType name="bookinfo">
          <xsd:sequence>
                <xsd:element name="title" type="titleinfo">
                <xsd:element name="author" type="xsd:string"/>
                <xsd:element name="year" type=" xsd:string"/>
                <xsd:element name="price" type=" xsd:string"/>
          </xsd:sequence>
    </xsd:complexType>

    The sub-elements author, year and price are of type xsd:string. The sub-element title is of complexType because it has an attribute named id. To define an attribute use the following: 

    <xsd:attribute name="id" type="xsd:string" use="required"/>

    Use value required means this attribute is mandatory. By default attributes are optional.

    Since XSD uses XML it is also extensible, and does not require learning a new language.

    To manipulate an XML document, we need an XML parser. The parser loads the document into a computer's memory and can be manipulated using the DOM. The DOM treats the XML document as a tree.

    XML is basically about defining data. XML is also used for storing data and sharing data between applications. With XML you can define documents that are understood by different software and applications. But to make these documents understandable to humans, your need to represent them. You can represent XML data using Cascading Style Sheets. But XSL is the preferred solution for converting XML documents into HTML. It can be used on the client side but the best solution is to use XSL on the server side and make it visible to any browser.

    XML usage increases every day. With XML, financial information can be exchanged over the Internet easily. We should expect to see a lot about XML and B2B (Business To Business) in the near future. XML is going to be the main language for exchanging financial information between businesses over the Internet. So why wait? Let’s learn more about XML and start using it today!


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · its very good to understand how and why the xml is used extensivly hope it is more...
       · Whenever i think about XML i think it's too hard by reading these article i get some...
     

    XML ARTICLES

    - Path, Predicates, and XQuery
    - Using Predicates with XQuery
    - Navigating Input Documents Using Paths
    - XML Basics
    - Introduction to XPath
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE
    - UI Design with Java and XML Toolkits
    - Displaying ADO Retrieved Data with XML Islan...
    - Widget Walkthrough
    - Introduction to Widgets
    - The Why and How of XML Data Islands
    - Creating an XUL App Installer
    - Overlays in XUL
    - Skinning Your Custom XUL Applications


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway