Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-05

DTD ENTITY question

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Adem

I am writing a general parser for DTD files and have made some headway.

I need to know the general (canonical?) name for '*%HTMLlat1*;' at the end of the following line:

<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin1//EN//HTML"
"HTMLlat1.ent">*%HTMLlat1*;

I don't seem to be able to find in documents/examples on the Net.

Does anyone know what such things are called?

Cheers, Adem -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100530/e229220b/attachment.html>

Reply by email

Sergei Gorelkin
to Adem
Adem wrote
I am writing a general parser for DTD files and have made some headway.

The FCL xml parser (xmlread unit) can parse XML-conformant DTD files for several years already.

Show quoted text 10 lines
I need to know the general (canonical?) name for '*%HTMLlat1*;' at the end of the following line: <!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin1//EN//HTML" "HTMLlat1.ent">*%HTMLlat1*; I don't seem to be able to find in documents/examples on the Net. Does anyone know what such things are called?

I'm not sure I understood your question correctly. Such constructs are called "parameter entities", very similar to an include file. The tag <!ENTITY % name PUBLIC "foo" "bar"> declares the entity, and %name; is used to actually include it.
The URI to retrieve such file depends on the language used; for XHTML 1.0 it will be "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent"

Regards,
Sergei

Reply by email

Adem
to Sergei Gorelkin
Sergei Gorelkin wrote 5 lines
Adem wrote: > I am writing a general parser for DTD files and have made some headway. > The FCL xml parser (xmlread unit) can parse XML-conformant DTD files for several years already.

I should've said a general SGML parser --not just a subset of it (XML)

Show quoted text 12 lines
> I need to know the general (canonical?) name for '*%HTMLlat1*;' at > the end of the following line: > > <!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin1//EN//HTML" > "HTMLlat1.ent">*%HTMLlat1*; > > I don't seem to be able to find in documents/examples on the Net. > > Does anyone know what such things are called? > I'm not sure I understood your question correctly. Such constructs are called "parameter entities", very similar to an include file.

Yes, it is a parameter entity declaration; an there's probably hundreds of such declarations in any DTD file worth its salt.

But, this is more than an ordinary parameter entity declaration.

I mean, a usual parameter entity definition would be as follows:

<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin1//EN//HTML" "HTMLlat1.ent">

but this one has a '%HTMLlat1;' attached to it after the close-tag.

Obviously, it is referring to the definition just made. Fine.

But, what do we call such a construct?

What is the general name for the adding stuff after the parameter definition?

The tag <!ENTITY % name PUBLIC "foo" "bar"> declares the entity, and %name; is used to actually include it.

IOW, the example above has already defined '%HTMLlat1;' so what is the point in adding (seemingly superfluous) '%HTMLlat1;' *after* the definition?

OK. I am not really asking why; all I want to know is what would the general name for such things?

Cheers, Adem

Reply by email

Sergei Gorelkin
to Adem
Adem wrote 7 lines
What is the general name for the adding stuff after the parameter definition? > The tag <!ENTITY % name PUBLIC "foo" "bar"> declares the entity, and > %name; is used to actually include it. IOW, the example above has already defined '%HTMLlat1;' so what is the point in adding (seemingly superfluous) '%HTMLlat1;' *after* the definition?

It's not superfluous. Defining the entity does not automatically include its content, it only tells the parser where to get this entity. Then, referencing an entity directs the parser to actually include its content. A single entity may be referenced multiple times. If an entity is never referenced, then its definition is obsolete and may be safely removed.

In your example, entity reference just happen to immediately follow the entity definition. There may be other constructs in between, e.g:

--- cut ---
<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "xhtml-lat1.ent"> <!ENTITY % HTMLsymbol PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" "xhtml-symbol.ent"> <!ENTITY % HTMLspecial PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" "xhtml-special.ent">

%HTMLlat1;
%HTMLsymbol;
%HTMLspecial;
--- cut ---
OK. I am not really asking why; all I want to know is what would the general name for such things?

A parameter entity definition followed by parameter entity reference.

Regards,
Sergei

Reply by email