Entity Declaration Clarification

I

Ian Rutgers

If I am using an DTD in an xml file I know to declare an entity I would
enter;

<!DOCTYPE letter
[
<!ENTITY boilerplate1 = "Thank you for your letter.">
]>

How and where would I declare the entity? (Sorry for the silly
question)

Thank you,

Ian
 
M

Martin Honnen

Ian said:
If I am using an DTD in an xml file I know to declare an entity I would
enter;

<!DOCTYPE letter
[
<!ENTITY boilerplate1 = "Thank you for your letter.">

That should be
]>

How and where would I declare the entity?

But the above is the declaration, I am not sure what the question is about.
Do you want to declare an external entity e.g.
<!ENTITY boilerplate SYSTEM "http://example.com/2005/01/boilerplate.xml">
?

Spec is here:
<http://www.w3.org/TR/2004/REC-xml-20040204/#sec-external-ent>
 
I

Ian Rutgers

I am sorry for not being clear. Can you declare an entity if you are
not using a DTD (using a schema instead)? (From what I have read you
must me using a DTD in order to declare an internal entity). If you can
declare internal entities and not have to use a dtd, please advise.

Thank you,

Ian
 
M

Martin Honnen

Ian said:
I am sorry for not being clear. Can you declare an entity if you are
not using a DTD (using a schema instead)? (From what I have read you
must me using a DTD in order to declare an internal entity). If you can
declare internal entities and not have to use a dtd, please advise.

No, you need to have a DOCTYPE declaration and then you can declare an
entity in the internal subset (the way you had it in your post) or in
the external subset (e.g. any DTD file referred to by SYSTEM
"whatever.dtd").
There is no way to declare an entity without having a DOCTYPE
declaration in the XML.
 
I

Ian Rutgers

Thank you. Would the general practice be not to use internal entities
or rather to use some generic dtd along with a schema?

Thank you,

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,838
Latest member
KandiceChi

Latest Threads

Top