Parameter entities |
|
Parameter entity problems |
|
I have done a lot of work building parameter entitie examples for this course. Most of them do not work reliabily in many environments. So, I have omitted them. I kept a couple of examples that work. They work, but are not very useful. You should look through this page briefly. Later, if you are working in an enviromnent where they work, you will have some familiarity with them. |
|
External parameter entity |
|
Usually, you write the DTD in a seperate file, not in the same file with the XML document. This allows the DTD to be used with many XML document files, all of which conform to the specifications of the same DTD. When using a parameter entity in a seperate DTD file, not with the XML document, we can say that it is an external parameter entity. An external parameter entiy is not in the same file with the XML document. An external parameter entiy can be very useful. It can be used within another entity. Its most valuable use is to provide common attributes, which are used in many attribute lists. For example, onFocus, onBlur, and several other attributes are used with many entities in XHTML. The list of common attributes can be written once within an external parameter entity, and then the external parameter entity can be used in many attribute lists.
You code a parameter entity that looks like the following:
When you use a parameter entity, it looks like the following: |
|
PUBLIC or SYSTEM parameter definition |
|
I have had so much trouble trying to use SYSTEM parameter definitions, that I suggest you ignore this topic. This is a description of how it should work. I have tried it with different wellformed checkers and DTD validators, including, validome.org, codeplot.com, xml copy editor, and firefox. The only thing I got to work is a SYSTEM parameter in an internal DTD, which is of very limited value. We have been talking about external parameter entities, that are in a DTD that is in a different file than the file containing the XML document. We will continue talking about external parameter entities.
In the last section we coded a parameter entity that looks like the following: It is also possible to use a parameter-definition that is in a different file from the DTD. So we have the XML document in one file, the DTD in a second file, and the parameter-definition in a third file.
If you want to use a parameter-definition that is in a different file within
your system, you code: The URI within your system is often just the file name within the same directory or the relative address near the current directory, as we have seen. It is also possible to use an absloute address, starting with the root directory of your system and working down through the directory levels to the file. It could even be the URL for another web server used by your organization.
You could even use a file provided by an external organization as your parameter definition.
You would code: |
|
Internal parameter entity |
|
You can write a parameter entity within an internal DTD. ( An internal DTD is one that is written within the XML document.) This is called an internal parameter entity. You specify the entity as you would with a general entity, Except use a % instead of an & Once you have created the entity, you can refer to it by using a percent sign, its name, and a closing semicolon. This is similar to a general entity, except it is used within the DTD, not within the XML code itself. Internal parameter entities cannot be used within any declaration. That means you cannot put them within an ELEMENT or ATTLIST. This limitation makes them more or less useless. |
|
The link takes you to an XML document.
In that document the entity |
|
The link takes you to an XML document.
In that document the entity |
|