Randy Gilman
Randy Gilman

Reputation: 457

White space error when dealing with DTD and XML

I have completed everything within my XML document but I am having trouble with a white space error. Specifically, it says "White space is required after the element type "element" in the element type declaration." My code is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 06 07:25:48 AST 2014 -->

<!DOCTYPE periodic
[
<!ELEMENT periodic (element+)>  
<!ELEMENT element(symbol, name, atomic_number, atomic_weight)><!-- Error is displayed here-->
<!ELEMENT symbol(#PCDATA)>
<!ELEMENT name(#PCDATA)>
<!ELEMENT atomic_number(#PCDATA)>
<!ELEMENT atomic_weight(#PCDATA)>]>

<periodic>
<element>  
  <symbol>FE</symbol> 
  <name>Iron</name> 
  <atomic_number>26</atomic_number>
  <atomic_weight>55.845</atomic_weight> 
</element>

<element>
  <symbol>Ir</symbol> 
  <name>Iridium</name> 
  <atomic_number>77</atomic_number>
  <atomic_weight>192.217</atomic_weight> 
</element>

<element>  
  <symbol>P</symbol> 
  <name>Phosphorus</name> 
  <atomic_number>15</atomic_number>
  <atomic_weight>30.973762</atomic_weight> 
</element>

<element>  
  <symbol>Uut</symbol> 
  <name>Ununtrium</name> 
  <atomic_number>113</atomic_number>
  <atomic_weight>284</atomic_weight> 
</element>

<element>  
  <symbol>Po</symbol> 
  <name>Polonium</name> 
  <atomic_number>84</atomic_number>
  <atomic_weight>209</atomic_weight> 
</element>
</periodic>

Any help would be greatly appreciated. Thank you.

Upvotes: 0

Views: 6858

Answers (1)

gusridd
gusridd

Reputation: 874

Actually a space is missing, you should add it after each element name declaration. So you should change:

<!DOCTYPE periodic
[
<!ELEMENT periodic (element+)>  
<!ELEMENT element(symbol, name, atomic_number, atomic_weight)><!-- Error is displayed here-->
<!ELEMENT symbol(#PCDATA)>
<!ELEMENT name(#PCDATA)>
<!ELEMENT atomic_number(#PCDATA)>
<!ELEMENT atomic_weight(#PCDATA)>]>

to this:

<!DOCTYPE periodic
[
<!ELEMENT periodic (element+)>  
<!ELEMENT element (symbol, name, atomic_number, atomic_weight)>
<!ELEMENT symbol (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT atomic_number (#PCDATA)>
<!ELEMENT atomic_weight (#PCDATA)>]>

Upvotes: 1

Related Questions