XML
  Home arrow XML arrow Page 6 - An Introduction to XML Schemas
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  
Moblin 
JMSL Numerical Library 
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

An Introduction to XML Schemas
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 12
    2004-11-03

    Table of Contents:
  • An Introduction to XML Schemas
  • Choose Your Schema
  • Element Declarations
  • Definitions and Elements
  • The Complete File
  • Validating a Document
  • A Few Final Tips

  • 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
     
     
    ADVERTISEMENT


    An Introduction to XML Schemas - Validating a Document


    (Page 6 of 7 )

    Now that you have your schema document, if you want to use it to validate a document, you have to link it to one. Open the document it is to be used with, in this case news.xml and add the following code to the root element:

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="newsSchema.xsd"

    This needs to be contained within the brackets of the root element, like this:

    <news xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="newsSchema.xsd">

    To use the location reference above, the XSD file needs to be in the same directory as the XML file. If the documents are in different directories, you’ll need to use the full path, with double forward slashes to properly escape the slash characters.

    Now save the XML document and open it in a browser; the document should load as normal in IE. To use IE to actually validate the XML document using the schema, you may need to change some of the settings of IE or download an additional plug-in; see the MSDN site for further information. As Schema documents are for use mainly in XML applications, if you want to use the schema to validate a document for your own purposes, it is best to visit an on-line validator that uses the schema to validate your XML document. An excellent on-line validator can be found at the following location:

    http://apps.gotdotnet.com/xmltools/xsdvalidator/Default.aspx

    If this is the case, and your XML document uses just text, it may be wiser to use a DTD.

    More XML Articles
    More By Dan Wellman


       · Hi,On page 3 of 7,...
       · Thanks for pointing that one out, a small error but one that will no doubt have...
     

    XML ARTICLES

    - Datatypes and More in RELAX NG
    - Providing Options in RELAX NG
    - An Introduction to RELAX NG
    - 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







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