473,320 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How can we validate a XML file using DTD?

Hi I Started reading XML bcz i have to learn SOAP... but when i go learn than some things realy annoyed me.... and i m here for a satisfactory help...
So here are the Problems....
1: how we can validate a XML file using DTD? i m having a DTD file like

i m having DTD file as

<!-- employee.dtd -->
<!ELEMENT employee (name, hiredate, salary)>
<!ATTLIST employee id CDATA #REQUIRED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT hiredate (#PCDATA)>
<!ELEMENT salary (#PCDATA)>


and the XML file like

<!DOCTYPE employee SYSTEM "employee.dtd">
<employee id="555-12-3434">
<hiredate>1997-12-02</hiredate>
<salary>42000.00</salary>
</employee>

here i have not entered the element <name> and opened the file in Explorer but
it not generated any error??? while i have declared in dtd that the xml file must contain <name > tag

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

Now can any one tell me how validation performed? it means by opening xml file in Explorer? or calling xml file through JavaScript ? or something else...
Oct 18 '07 #1
1 4290
phvfl
173 Expert 100+
Hi I Started reading XML bcz i have to learn SOAP... but when i go learn than some things realy annoyed me.... and i m here for a satisfactory help...
So here are the Problems....
1: how we can validate a XML file using DTD? i m having a DTD file like

i m having DTD file as

<!-- employee.dtd -->
<!ELEMENT employee (name, hiredate, salary)>
<!ATTLIST employee id CDATA #REQUIRED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT hiredate (#PCDATA)>
<!ELEMENT salary (#PCDATA)>


and the XML file like

<!DOCTYPE employee SYSTEM "employee.dtd">
<employee id="555-12-3434">
<hiredate>1997-12-02</hiredate>
<salary>42000.00</salary>
</employee>

here i have not entered the element <name> and opened the file in Explorer but
it not generated any error??? while i have declared in dtd that the xml file must contain <name > tag

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

Now can any one tell me how validation performed? it means by opening xml file in Explorer? or calling xml file through JavaScript ? or something else...
Hi,

Could you please use code tags as it makes the post easier to read. There is information of how to validate custom DTDs here. This article is related to XHTML which is just an XML document corresponding to a specific DTD so the method for validation would be the same
Oct 18 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: AJM | last post by:
I am having a problem getting the schema validation to work. Using any of the samples, i.e. SAXCount DOMCount DOMPrint etc, when trying to run the v=always option and then using the...
0
by: Ray Tayek | last post by:
hi, fooling around with xmlspy (which seems pretty broken when *doing* xslt's). trying to validate in java using code from http://cermics.enpc.fr/doc/java/j2eetutorial-1.4/doc/JAXPSAX13.html...
0
by: Aaron P Frenger | last post by:
Hello All, I have a very large XML file that I would like to split up into a few smaller files, but still use only one schema. I am using Xerces C++ libraries. My idea is to have one schema...
8
by: Dean Speir | last post by:
Hi... I've been referred to this Newsgroup by the W3C Markup Validator FAQ. I've been happily using this Validator <http://validator.w3.org> for the past 18 months with great success, but...
9
by: Rob Mayo | last post by:
I have a bunch of XSD files in my assembly as embedded content that are read out via reflection and streams. My app creates the XML on the fly, and I want to validate it using the schema files...
1
by: aevans1108 | last post by:
Greetings All If this is the wrong place to post this question, please give me a push in the right direction. Thanks. I know there has to be a simpler way to do this, but this is as simple a...
0
by: SHC | last post by:
Hi all, I have a VC++ .NET 2003 - Windows XP Pro PC. I created a Win32 console application in my VC++ .NET 2003 and copied validateDOM.cpp, books.xml and books.xsd (see the attached files below)...
7
by: Ali-R | last post by:
Hi all, I am getting a CSV file like this from our client: "C1","2","12344","Mr","John","Chan","05/07/1976"......... I need to validate **each filed value** against a set of rules ,for...
3
by: Rushi | last post by:
Hi All, Is it possible to Validate XML against XSD using two different XML files. scenario: There are two different XML file, one file contain element and count information and other one...
6
by: Jonny | last post by:
Hi, I'm trying to validate my xml against a xsd but I can't get it to work. Originally, I wanted to validate an xml string but since I didn't get that to work I tried to validate an xml file...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.