外部dtd(xml)中的外部实体引用

时间:2022-02-02 20:18:46

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

我在外部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...

当我在Internet Explorer上运行此程序时,我收到错误...

1 个解决方案

#1


8  

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

那是因为您使用ELEMENT声明来声明实体。

This is what your ENTITY declaration should look like:

这是您的ENTITY声明应如下所示:

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

此外,您的示例中有[name.dtd],但系统标识符显示simple.dtd。确保您的系统标识符指向正确的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>

#1


8  

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

那是因为您使用ELEMENT声明来声明实体。

This is what your ENTITY declaration should look like:

这是您的ENTITY声明应如下所示:

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

此外,您的示例中有[name.dtd],但系统标识符显示simple.dtd。确保您的系统标识符指向正确的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>