![]() |
|
| • All Online Courses • New Courses • QuickTips • Word Definitions • Submit a Tutorial • Links • |
|
Learn XML programming in this free XML training course How do you declare empty elements?Sometimes, you need to create an element that doesn’t have anything in it at first, so that data can be placed into it by either an end user or by the XML program itself. The problem with this is that you have to create the element, but not define any data within it… something that’s not easily accomplished in a lot of programming languages. Luckily, XML is prepared to handle this situation with the appropriately-named EMPTY validation rule for elements. You may remember seeing EMPTY on the list of validation rules earlier… it might even have struck you as a bit odd to see something that created elements with nothing in them. Elements created this way often have attributes associated with them that have meaning and values, thus using the empty element as somewhat of a placeholder for the other attributes. To create an empty element, use the following format: <!element cats_info EMPTY> Wherein cats_info would be the element that you were creating to be empty. What is some of the jargon used with entities?Different jargon is used with various entities to effect the processing of XML codes in different ways. Attribute lists can be created for entities dealing with multiple attributes, and data referenced by entities can be either required or implied. To create an attribute list, begin by declaring the name of the list, like so: <!attlist cat_characteristics The attlist stands for attribute list, and cat_characteristics is the name of the list. From there, it’s time to begin listing attributes. <!attlist cat_characteristics hair_length hair_color name > Note that the closing > was placed on a line of its own. This makes things a lot easier if you have to add or modify any of the listings… just make sure that you don’t forget it. As was mentioned a moment ago, data can also be either required or implied. What this means is that the data may or may not be present when the XML file first begins to run, and through use of the #required and #implied tags you can create rules to let the program know whether it needs the information at onset or not. Required means that the data is present when it begins to run and thus is available for use, and implied means that it might not be present so it shouldn’t try to access it until it’s been defined elsewhere. Using these to define rules for attributes would look like this: <!attlist cat_characteristics hair_length #implied hair_color #required name #required > This way, the attributes hair_color and name are defined somewhere, and therefore are required… hair_length, on the other hand, might not be, so it shouldn’t be accessed yet.
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