![]() |
|
| • All Online Courses • New Courses • QuickTips • Word Definitions • Submit a Tutorial • Links • |
|
Learn XML programming in this free XML training course What is a Document Type Declaration?The Document Type Declaration is something that you should be familiar with as well. In the previous examples where you encountered <!doctype> and <!element>, those are the beginnings of document type declarations. All that a document type declaration does is let the browser know that you’re defining a part of a document, and gives it an idea of what part of the document you’re defining. While document type declarations are used to define the rules for a root element in a DTD as well as the DTD itself, they can be used in other circumstances as well. If you have several elements that are contained within another element, you can use a document type declaration to declare that they’re contained elements. In cats.xml, you created the elements cats and friends within the root element, cats_info. If all of that was a part of a larger document, though, you might want to make cats and friends as elements contained within cats_info, which would then be a container element instead of a root element. The declaration for your DTD to connect these three elements would look something like this: <!element cats_info (cats, friends)> Notice that the contained elements are in parenthesis, and are separated by commas. Elements with namespaces can be contained in this manner as well, but need to be referred to by their full names… in other words, you’d use the following instead: <!element cats_info (my_cats:cats, my_cats:friends)> Any number of elements may be contained in the group, and they don’t necessarily have to be declared in the same order as they appear in the XML document. For the sake of consistency, though, it’s a good idea… that way, you don’t have to keep searching because they’re listed out of order in the DTD. What is a PUBLIC source specifier?Source specifiers are fancy terms for the bit of code that tells your XML document where to find what it’s looking for. If you use the PUBLIC source specifier, then you’re referencing an external DTD that’s held somewhere other than on your system. The PUBLIC keyword lets your program know that it’s going to be searching elsewhere for the information that it wants, and the source that you provide (usually in URL form) tells it where to go to find it. As an example, let’s take the previously-mentioned cats.dtd as a source. You may remember that it looked a little something like this: <!doctype cats_info SYSTEM “cats.dtd”> Unfortunately, for this scenario we’ll assume that you’re working with someone else, and they have the .dtd file on their system. Looks like it’s the PUBLIC keyword to the rescue! <!doctype cats_info PUBLIC “cats.dtd” “http://www.anothercatsite.net/cats.dtd”> Notice that the full URL for the resource was given, so that the program would know exactly where to look for the DTD file.
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