简体   繁体   中英

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...

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM