Are schemas better than DTDs for defining entities?

C

Curious

Defining your own Entities in a DTD is rather pointless because Firefox &
certain other browsers don't read the DTD.
Is there a similar mechanism in schemas which works for all browsers?
 
J

Joe Kesselman

Is there a similar mechanism in schemas which works for all browsers?

Entities are one of the DTD features which was *not* carried forward to
Schemas. The assumption was that people would use other mechanisms --
XInclude, inline XPointer, possibly stylesheet-assisted -- to implement
named-block/macro referencing. Or do server-side inclusion.

I haven't done a survey recently, so I don't know what's safe to assume
for "all browsers". But one of those standards-based approaches might do
the job for you.
 
B

Bjoern Hoehrmann

* Curious wrote in comp.text.xml:
Defining your own Entities in a DTD is rather pointless because Firefox &
certain other browsers don't read the DTD.

They do, if you put the code in the internal subset rather than in some
external document. There is no other way, except perhaps using scripts
that dynamically load content, but then I am not sure what the point is.
 
P

Peter Flynn

Curious said:
Defining your own Entities in a DTD is rather pointless because Firefox &
certain other browsers don't read the DTD.

Browsers don't read an external DTD. Declared entities appear to work in
browsers if you put the DTD in the internal subset of the document. In
general, browser support for XML at the moment is poor and should be
avoided in favour of server-side support where possible.
Is there a similar mechanism in schemas which works for all browsers?

Not as such. W3C Schemas don't have a concept of entities. XML entities
were inherited from SGML, and they continue to be important for normal
text document work, but W3C Schemas are targeted more at describing data
structures than text documents.

///Peter
 
C

Curious

I tried defining an entitiy in the internal dtd using the files "simple.xml"
and "navbar.xml" shown below. This did not work with Firefox 2.0.0.3. Only
the title text was displayed.

simple.xml file
--------------
<?xml version="1.0"?>
<!DOCTYPE book SYSTEM "book.dtd"[
<!ENTITY navbar SYSTEM "navbar.xml">
]>
<book>
<title>The Wit and Wisdom of George W. Bush</title>
&navbar;
</book>


navbar.xml file
---------------
<h1>This is the navbar text</h1>



Curious.
 
R

Richard Tobin

Curious said:
I tried defining an entitiy in the internal dtd using the files "simple.xml"
and "navbar.xml" shown below. This did not work with Firefox 2.0.0.3. Only
the title text was displayed.
<!ENTITY navbar SYSTEM "navbar.xml">

I don't think most browsers read external entities any more than they
read the external subset. It would probably have worked if you did

<!ENTITY navbar "<h1>This is the navbar text</h1>">

though that may not be much use to you.

-- Richard
 

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
474,008
Messages
2,570,268
Members
46,867
Latest member
Lonny Petersen

Latest Threads

Top