Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 280181

Explain this XML entity notation and reference

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>

Upvotes: 1

Views: 560

Answers (3)

Daniel Haley
Daniel Haley

Reputation: 52888

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

Upvotes: 2

user1943931
user1943931

Reputation:

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.

Upvotes: 2

Oded
Oded

Reputation: 499382

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

Upvotes: 2

Related Questions