abhijeet
abhijeet

Reputation: 479

External entity reference in external dtd (xml)

i have little bit of problem while working with External entity reference in External DTD

for Example

[name.xml]

<?xml version="1.0" ?>
<!DOCTYPE simple SYSTEM "simple.dtd">
<simple>
       <name> &a;   </name>
       <age>  21   </age>
       <address> bsk street </address>  
</simple>

[name.dtd]

<?xml version="1.0" ?>
<!ELEMENT simple (name,age,address)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT a "abhijeet">

when i run this program on the Internet Explorer i am getting error...

Upvotes: 3

Views: 6033

Answers (1)

Daniel Haley
Daniel Haley

Reputation: 52888

That's because you're using an ELEMENT declaration to declare an entity.

This is what your ENTITY declaration should look like:

<!ENTITY a "abhijeet">

Also, you have [name.dtd] in your example, but your system identifier shows simple.dtd. Be sure your system identifier is pointing to the correct DTD.

Example of internal subset:

<?xml version="1.0"?>
<!DOCTYPE simple SYSTEM "simple.dtd" [
<!ENTITY a "abhijeet">
]>
<simple>
  <name> &a;   </name>
  <age>  21   </age>
  <address> bsk street </address>
</simple>

Upvotes: 9

Related Questions