New Message on dotNET User Group Hyd

XML schema

Reply
  Reply to Sender   Recommend Message 2 in Discussion
From: dharmesh17

Validate an XML Document

While using Internet Explorer to load XML files linked to a DTD allows some ability to debug DTD errors, the main point of a having a DTD will be to validate XML documents to the DTD itself.

Validating XML documents ensures that in addition to being well-formed, a document conforms to the content rules that are defined in the DTD. You can perform validation easily enough using one of the following Microsoft online validation tools:

XML Validator
This web page allows you to paste in the contents of an XML document and both parse and validate that document to an inline DTD or you can simply use it to check the well-formedness of any XML string you paste in as Web form input.
XSD Schema Validator
This page allows you to validate an XML documents against an W3C XML Schema (XSD) or an XML Data-Reduced (XDR) schema, verify the schemas are valid, or simply check the well-formedness of XML documents.

Example: Validating an XML document to an external DTD

The following example includes the following:

  • An external DTD file.
  • An XML file, books.xml, that is well-formed but contains a validation error.
  • Step-by-step instructions for using the Internet Explorer tool for validating XML. This tool is freely available from Microsoft Developer Network (MSDN) Online.

DTD File (books.dtd)

<!ELEMENT catalog    (book+) > <!ELEMENT book       (author, title, genre, price, publish_date, description) > <!ATTLIST book       id ID #REQUIRED > <!ELEMENT author         (#PCDATA)   > <!ELEMENT title          (#PCDATA)   > <!ELEMENT genre          (#PCDATA)   > <!ELEMENT price          (#PCDATA)   > <!ELEMENT publish_date   (#PCDATA)   > <!ELEMENT description    (#PCDATA)   >

XML File (books-well-formed.xml)

<?xml version="1.0"?> <!DOCTYPE catalog SYSTEM "books.dtd"> <catalog>    <book id="bk101">       <author>Gambardella, Matthew</author>       <title>XML Developer's Guide</title>       <genre>Computer</genre> <!-- The following line is not valid according to books.dtd. -->       <cost>44.95</cost>       <publish_date>2000-10-01</publish_date>       <description>An in-depth look at creating applications with       XML.</description>    </book> </catalog>

Try It!

  1. Open Internet Explorer and navigate to the XML General Downloads page on MSDN online located at http://msdn.microsoft.com/downloads/list/xmlgeneral.asp.
  2. In the Tools section, click Internet Explorer Tools for Validating XML and Viewing XSLT Output.

    The download page for Internet Explorer Tools for Validating XML and Viewing XSLT Output should appear.

  3. Follow the instructions on the download page for downloading and installing the Internet Explorer XML tools.
  4. Open Notepad.
  5. Copy books.dtd. Paste it into the Notepad window.
  6. From the File menu, click Save As. Save the file as books.dtd to a folder on your computer.
  7. Copy books-well-formed.xml. Paste it into the Notepad window.
  8. From the File menu, click Save As. Save the file as books-well-formed.xml to the same folder in which you saved books.dtd.
  9. In Windows Explorer, double-click on books-well-formed.xml to open it in Internet Explorer.
  10. In the browser window, right-click and select Validate XML.

Output

A message box will appear in the browser window with a validation message similar to the following format:

Parse Error at line 9 in file:///C:/New Folder/books.dtdSource:        <COST>44.95</COST>Element content is invalid according to DTD/Schema.Expecting: price.

The above artical can be accessed at http://msdn.microsoft.com/library/default.asp?url="">
 
Hope This Helps:-)
 

View other groups in this category.

Click here
Also on MSN:
Start Chatting | Listen to Music | House & Home | Try Online Dating | Daily Horoscopes

To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.

Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.

If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.

Reply via email to