troubleshooting Question

Using external DTD to define entities

Avatar of lfgreen
lfgreen asked on
Web Languages and StandardsXML
6 Comments1 Solution888 ViewsLast Modified:
I am trying to use a DTD to define a set of entities. I am not interested in performing any other kind of validation. A number of documents use these entities, so I want them to all be defined in the same place. My DTD file looks like this:

  <?xml version="1.0" encoding="UTF-8"?>
  <!ENTITY entity1 "declaration1">
  <!ENTITY entity2 "declaration2">
  <!ENTITY entity3 "declaration3">

Based on other answers I have read on Experts Exchange, I have also tried this:

  <?xml version="1.0" encoding="UTF-8"?>
  <!ENTITY % entity1 SYSTEM "declaration1">
  <!ENTITY % entity2 SYSTEM "declaration2">
  <!ENTITY % entity3 SYSTEM "declaration3">

XMLSpy declares these to be well-formed, but my browser (Firefox and IE) won't parse or display the DTD. IE gives me an error like this:

Cannot have a DTD declaration outside of a DTD. Error processing resource 'http://www.mysite.com/entities.dt...

  <!ENTITY % entity1 SYSTEM "declaration1">
-------------^


I have two questions:
  1) If I want to use a DTD this way, how should it be formatted? (I don't want any ELEMENT declarations or any sort of well-formedness rules) Is there something other than a DTD I could use to do this?
  2) What declaration should I put in my XML files for them to include the entity definitions? In particular, does this document have a DOCTYPE? If so, what is it?

As I understand, I need to use a declaration like this:
<!DOCTYPE type SYSTEM  http://www.mysite.com/entities.dtd>

but I don't know exactly what to put here.


I have done this using internal DTDs and it works fine, but I want to centralize all of these entity declarations so they're easier to track and change. How can I do this?


Thank You.
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)
Information Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2006

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004