![]() |
|
| • All Online Courses • New Courses • QuickTips • Word Definitions • Submit a Tutorial • Links • |
|
Learn XML programming in this free XML training course What is a SYSTEM source specifier?If you’re using a SYSTEM source specifier, then you’re simply including a reference to a .dtd file or other resource that’s located on the same system as the file that the browser’s reading from. As with many of the items in this part of the tutorial, you’ve already seen this; a SYSTEM source specifier was used in the initial example of an external DTD. When declaring a source using SYSTEM, then it’s initially assumed to be in the same directory as the XML document that references it. Take the example from above: <!doctype cats_info SYSTEM “cats.dtd”> Whatever folder or directory the cats.xml file is in, that’s the folder or directory that it’s going to search for the cats.dtd file. This can cause problems if the file is in a subdirectory… that’s why you always need to make sure that you spell out the exact location of the file if you don’t have them both in the same directory. If you keep all of your .dtd files in a subdirectory named DTD, you need to specify it. <!doctype cats_info SYSTEM “/DTD/cats.dtd”> You don’t need to put the entire path in there, though… just the path from the current directory to the one that contains your files. (If the .dtd file is contained in another directory that’s not directly connected with the one your XML file is in, then you need to supply the entire path for it… and you also might want to consider using subdirectories to make things a little easier.) How do you declare entities?One useful thing that you can do with DTD’s is the creation of entities. An entity can exist in various forms within XML… one type of entity, known as a parameter entity, is a piece of text that can be referenced repeatedly without having to retype it every time. It’s kind of like being able to create your own form of shorthand within the DTD, so that you can use a much smaller letter combination to refer to a larger string of text. As an example, let’s take the names of our cats, Tooter and Shade. Instead of manually typing “Tooter and Shade” every time we encounter the pairing like that in our DTD, we can create the entity, TS, to represent the longer phrase. The syntax for doing this looks a little something like this: <!ntity % TS “Tooter and Shade”> Now, every time we need to have “Tooter and Shade” appear within our DTD, we can simply substitute TS in its place and the browser will know what we mean. Note the exclamation point, the percentage sign, and the quotes are all needed for the code to work correctly. Other entities known as general entities can be used to define other types of text or data. For instance, if we’re wanting to reference a picture of our favorite felines throughout different parts of a larger document, we might want to create an entity that would represent that picture. The declaration will look a little different, but the end result will be the same… having a smaller object that we can substitute for a larger filename. Here’s what it would look like: <!entity PIC SYSTEM “tooter_and_shade.gif” ndata gif> The ndata gif part of the entity declaration lets the code know that it’s dealing with a .gif image, and the SYSTEM tag tells it to search the system folder or directory for a picture named tooter_and_shade.gif. Whenever the document encounters the entity named PIC afterwards, it will know to substitute the picture in the entity’s place.
by John Casteele Find more free Internet tutorials from Learnthat.com. More Information:
Help us by rating this tutorial: [---] [--] [+] [++] [+++] [---] lowest; [+++] highest
|
|
||||||
![]() |
Learn: Free
Tutorials - Links
to Free Tutorials
Understand: Free Technical Definitions
- ExplainThat Whitepapers
Use: Certification Section -
Discussion Forum
Visit Our Network Sites:
About Us : Contact Us : Advertise : Privacy Information