Results 1 to 6 of 6

Thread: How to Validate XML Against a DTD?

  1. #1
    Join Date
    Jul 2006
    Posts
    128

    How to Validate XML Against a DTD?

    I have done many programs in XML. But now I am stuck at a point. I am not able to validate XML in a DTD. I have tried to do lot of things but was not successful in getting a desirable output. Can anyone explain me how to Validate XML Against a DTD? It will be much appreciable, if someone provides the helpful sample of codes. Please help me as soon as possible.!!
    "Every man is guilty of all the good he did not do". - Voltaire

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: How to Validate XML Against a DTD?

    You should know that the validation check is performed against any XML schema or DTD declared inside the XML document. Only a syntax check is performed, if you are not declaring an XML schema nor a DTD. Also errors in XML documents will stop your XML applications. Also I would like to tell you that the HTML browsers will display documents with errors. Errors like the missing end tags and tags similar to that. HTML browsers are big and incompatible because they have a lot of unnecessary code to deal with HTML errors.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: How to Validate XML Against a DTD?

    XMLBlueprint can validate any XML Document against any valid DTD. For validating an XML Against a DTD, follow the steps given below :
    1. First open your XML Document in the XML Editor.
    2. Then click on the XML. Then select the option validate.

    You will also have to keep in mind that to validate an XML Document you need to associate your XML Document with a DTD, Schematron Schema, Relax NG Schema, or XML Schema. If there is any errors in your XML documents, then the Output Window is automatically displayed to show the errors.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: How to Validate XML Against a DTD?

    You can use the following code sample for validating XML Against a DTD :
    You will need to associate your XML Document with the DTD, if you want to validate an XML Document against a DTD (Document Type Declaration). The following code is an example for that :
    HTML Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//Welcome//DTD XHTML 1.0 Strict//EN" "http://www.xml.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.xml.org/2010/xhtml">
    </html>
    The above example tells XMLBlueprint to validate the XML Document against DTD.
    "http://www.xml.org/TR/xhtml1/DTD/xhtml1-strict.dtd".

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to Validate XML Against a DTD?

    You can check for DTD errors, if you are using the Internet Explorer as the browser, for loading the files. But you will need to set the value of validateOnParse to True prior to loading a file into the XML DOM for using your DTD to validate an XML file. Because an Internet Explorer leaves this property set to False as its default for loading XML file types. Hope that this information will help you.!!

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: How to Validate XML Against a DTD?

    I know how to validate a xml file against a DTD (Document Type Definition), but using the DOM APIs. I am providing you with an example, in which the DTD defines the document structure with a list of legal elements and attributes. The main thing for validating a XML file against a DTD needs a xml file and its DTD document. For that purpose you will have to construct a well-formed xml file along with a DTD file. Here is the
    Code:
    xml file : 
    <?xml version = "1.0" ?>
    <!DOCTYPE Employee SYSTEM "Student.dtd">
    <Student>
    <Stu_Id> E-001 </Stu_Id>
    <Stu_Name> Sewre </Stu_Name>
    <Stu_E-mail> Sewre@yahoo.com </Stu_E-mail>
    </Student>
    Then here is an example of the DTD file :
    <!ELEMENT Student (Stu_Id, Stu_Name, Stu_E-mail)>
    <!ELEMENT Stu_Id (#PCDATA)>
    <!ELEMENT Stu_Name (#PCDATA)>
    <!ELEMENT Stu_E-mail (#PCDATA)>
    Hope that these examples will help you a lot..!

Similar Threads

  1. Need help to validate windows 7 on macbook pro
    By Atalaya in forum Operating Systems
    Replies: 5
    Last Post: 10-11-2010, 12:14 AM
  2. How to validate page in ASP.NET
    By MaggieK in forum Software Development
    Replies: 5
    Last Post: 12-02-2010, 01:56 AM
  3. How to Validate Email by using PHP?
    By NGV BalaKrishna in forum Software Development
    Replies: 5
    Last Post: 07-02-2010, 02:43 AM
  4. How to validate windows XP
    By austin26 in forum Operating Systems
    Replies: 3
    Last Post: 18-11-2009, 05:47 PM
  5. Using php how can we Validate doc,txt,pdf files
    By Santanio in forum Software Development
    Replies: 2
    Last Post: 14-05-2009, 01:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,601,618.10512 seconds with 17 queries