1

Given the following XML file, what do the DOCTYPE, ENTITY, SYSTEM, &entity (reference?) represent?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root [
        <!ENTITY entity SYSTEM "./entity.xml">
]>

<root>
    <element attribute="value">
        &entity; 
        <child>
           <!-- some more nested -->
        </child>
    </element>
</root>
4

3 回答 3

2

It is the schema of the XML, in DTD format.

于 2013-01-04T19:27:03.463 回答
2

The DOCTYPE declaration is specifying the root element (root).

The entity declaration (ENTITY) is pointing to the file entity.xml on the system (SYSTEM).

The entity reference (&entity;) references the entity declaration named entity. The easiest way to think of it is that &entity; is replaced with everything that is in entity.xml.

Here's a good link that covers entities (including parameter entities): http://www.w3.org/TR/2004/REC-xml-20040204/#sec-entity-decl

于 2013-01-04T19:30:54.337 回答
2

It is the format in which the XML is written. This is specifically written in DTD format. For more information I suggest this guide that quickly explains how to read and understand said DTD format.

Also for more information about entities specifically, try this link as well.

于 2013-01-04T19:30:57.407 回答