...

View Full Version : What is wrong with my dtd code?



gabald_28
03-06-2009, 08:49 PM
Hello, I am having an error message when I try to validate my code. Can someone please let me know what is wrong with the dtd file. Thank you.
DTD:

<?xml version="1.0" encoding="utf-8"?>

<!ELEMENT patients_info (patients+)>
<!ELEMENT patients (first_name, middle_name, last_name, social, age,
room_number, primary_insurance, secondary_insurance, med_history, drug_allergies)>
<!ELEMENT first_name (#PCDATA)>
<!ELEMENT middle_name (#PCDATA)>
<!ELEMENT last_name (#PCDATA)>
<!ELEMENT social (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT room_number (#PCDATA)>
<!ELEMENT primary_insurance (insurance_name ,phone , id , group, address)>
<!ELEMENT secondary_insurance (insurance_name ,phone , id , group, address)>
<!ELEMENT med_history (#PCDATA)>
<!ELEMENT drug_allergies (#PCDATA)>

XML

<?xml version="1.0" encoding="utf-8"?>
<?DOCTYPE patients_info SYSTEM "patients.dtd"?>
<?xml-stylesheet type = "text/css" href = "patients.css"?>

<patients_info>

<pagetitle>
<![CDATA[
Patients Information]]>
</pagetitle>

<!--patient 1 -->

<patients>
<first_name>Kate</first_name>
<middle_name>Michelle</middle_name>
<last_name>Cusse</last_name>
<social_security>Social Security #: 123456789</social_security>
<age> Age: 24</age>
<room_number>Room: 103</room_number>
<primary_insurance>
<insurance_name>Blue Cross</insurance_name>
<id>ID:12345</id>
<group>Group#:2</group>
<phone> (770)123-4567</phone>
<address>Address: 123 Main Street,GA 30023.</address>
</primary_insurance>

<secondary_insurance>
<insurance_name> Humana</insurance_name>
<id> ID: 14532</id>
<group>Group#:2</group>
<phone>(770) 123-8325</phone>
<address>Address: 143 Main Street, GA 30023.</address>
</secondary_insurance>
<med_history>High Cholesterol</med_history>
<drug_allergies>NA</drug_allergies>
</patients>

<!--patient 2 -->
<patients>
<first_name>James</first_name>
<middle_name>Paul</middle_name>
<last_name>Smith</last_name>
<social_security>Social Security #:124456725</social_security>
<age>Age: 22</age>
<room_number>Room: 107</room_number>
<primary_insurance>
<insurance_name>Blue Cross </insurance_name>
<id>ID:15532</id>
<group>Group#:2</group>
<phone>(770)123-6732 </phone>
<address>Address: 123 Main Street,GA 30023.</address>
</primary_insurance>

<secondary_insurance>
<insurance_name>Humana</insurance_name>
<phone> (678) 576-8635 </phone>
<id> ID: 17532</id>
<group>Group#:2</group>
<address> Address: 143 Main Street, GA 30023.</address>
</secondary_insurance>
<med_history>High Blood Pressure</med_history>
<drug_allergies>NA</drug_allergies>
</patients>

<!--patient 3 -->
<patients>
<first_name>Nick</first_name>
<middle_name>Ryan</middle_name>
<last_name>Zell</last_name>
<social_security>Social Security#: 123456789</social_security>
<age> Age: 30</age>
<room_number>Room: 201</room_number>

<primary_insurance>
<insurance_name>Blue Cross </insurance_name>
<phone> (770) 245-5725</phone>
<id>ID:18945</id>
<group>Group#:3</group>
<address>Address: 123 Main Street,GA 30023.</address>
</primary_insurance>

<secondary_insurance>
<insurance_name>Humana</insurance_name>
<phone> (678)737-9397 </phone>
<id>ID: 17853</id>
<group>Group#:2</group>
<address>Address: 143 Main Street, GA 30023.</address>
</secondary_insurance>

<med_history>Cancer</med_history>
<drug_allergies>NA</drug_allergies>
</patients>

<!-- Patient 4 -->
<patients>
<first_name>Alan</first_name>
<middle_name>James</middle_name>
<last_name>Wilkes</last_name>
<social_security>Social Security #: 346248935</social_security>
<age>Age: 45</age>
<room_number>Room: 109</room_number>
<primary_insurance>
<insurance_name>Blue Cross </insurance_name>
<phone> (687) 782-6306 </phone>
<id>ID:56723</id>
<group>Group#:1 </group>
<address>Address: 123 Main Street,GA 30023.</address>
</primary_insurance>

<secondary_insurance>
<insurance_name>Humana</insurance_name>
<phone> (357)620-3296</phone>
<id>ID: 54246</id>
<group>Group#:3 </group>
<address>Address:143 Main Street, GA 30023.</address>
</secondary_insurance>

<med_history>Healthy</med_history>
<drug_allergies>NA</drug_allergies>
</patients>

</patients_info>

oesxyl
03-06-2009, 09:02 PM
<?xml version="1.0" encoding="utf-8"?>
<?DOCTYPE patients_info SYSTEM "patients.dtd"?>
<?xml-stylesheet type = "text/css" href = "patients.css"?>

<patients_info>

<pagetitle>
<![CDATA[
Patients Information]]>
</pagetitle>



the xml not follow the structure declared in dtd. At first look youd don't have any pagetitle as subnode of patients_info

best regards

gabald_28
03-06-2009, 09:11 PM
<?xml version="1.0" encoding="utf-8"?>
<?DOCTYPE patients_info SYSTEM "patients.dtd"?>
<?xml-stylesheet type = "text/css" href = "patients.css"?>

<patients_info>

<pagetitle>
<![CDATA[
Patients Information]]>
</pagetitle>



the xml not follow the structure declared in dtd. At first look youd don't have any pagetitle as subnode of patients_info

best regards

The problem is in the dtd file where I get an error. The XML validated.

oesxyl
03-06-2009, 09:43 PM
The problem is in the dtd file where I get an error. The XML validated.
post the error message, please.

best regards

gabald_28
03-06-2009, 09:49 PM
post the error message, please.

best regards
I get two errors:
<!ELEMENT patients_info (patients+)> // Error-Expected Comment or CDATA[xml]

<!ELEMENT first_name (#PCDATA)> //Error-An exception occurred! Type:EmptyStackException, Message:The element stack is empty[xml]
Thank you for helping.

oesxyl
03-07-2009, 12:04 AM
XML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE patients_info SYSTEM "patients.dtd"?>

- doctype start with <! not <?
- add this in dtd before patients and remove your patiens_info


<?xml encoding="UTF-8"?>
<!ELEMENT patients_info (pagetitle,patients+)>
<!ATTLIST patients_info xmlns CDATA #FIXED ''>

<!ELEMENT pagetitle (#PCDATA)>
<!ATTLIST pagetitle xmlns CDATA #FIXED ''>


best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum