Posted on 2000-02-23
Last Modified: 2008-03-03

I don't understand the way the IMPLIED works. In some tutorial I red that it means you are providing an implied default value for an attribute. As oposed to REQUIERED where you just mention that it will be checked if that attribute is there, but you do not provide any value for it.
This is done in the .dtd file.
But the tutorial does not provide any value for that attribute in the .dtd file ? Where will you provide the default value ?

That's from the tutorial:

name            NMTOKEN #REQUIRED
hostName        NMTOKEN #IMPLIED
function        %funcType; #REQUIRED
number          CDATA #REQUIRED
type            %serverType;
serverPort      %fbool;

Question by:simi
  • 2
LVL 19

Expert Comment

ID: 2554674
Over view:
Value Explanation
#DEFAULT value
 The attribute has a default value
 The attribute value must be included in the element
 The attribute does not have to be included
#FIXED value
 The attribute value is fixed

The REQUIRED flag specifies that though there is no default value provided by the DTD, the attribute when actually implemented in an XML document must define a value. For example, suppose you wanted to define a standard PAGE_AUTHOR element that could be added to every page on any site that used it. Your intent is to make sure that every author provides contact information for bugs and broken links. However, you won't know in advance what the default values should be because everyone who implements your DTD will have different personal information. Thus, you can make the contact information attributes required, while not providing defaults.

When you use the IMPLIED default, you will provide a default value for the document author. If the document author does not override your default, your default will be used.

FIXED Default
Sometimes you will want to provide a default value that the document author may not modify. In that case, you will use FIXED.

also check out:


Author Comment

ID: 2555301
Thanks but your answer is nothing but cut and paste from the same site I have posted the DTD example.
The reason why I was asking the question was because I did not understand from the tutorial exactly what your answer is stating.
What I do not understand is where do you specifi the implied value.
If not in the .dtd file then where ?
A .dtd file can be used by multiple .xml files as a document type definition.
When at creation of the .dtd you do not know what will be the value for a certain attribute, but you know you want all .xml files having such a value you use #REQUIRED.
When you use #IMPLIED you should provide a default value, that is used if the .xml file does not overrite it by providing one. That's why it is not necesarry needed, like with a required one.
If there was a place to put the implied value itself that would be the .dtd file, but the example we are both talking about is not doing that.
This is my question. Where do I place the default value of the #IMPLIED attribute ?

LVL 19

Expert Comment

ID: 2555750
not in the dtd but in the .xml (atleast thats what my reading lead me to believe, I will check more tonite)


Accepted Solution

dmaryakh earned 25 total points
ID: 2559145
#IMPLIED - It is optional to supply a value for this attribute in the document instance; applications will beed to supply their own value if one is needed for processing.

#REQUIRED  - a value must be supplied for the attribute in the documents instance.

As for your question of where would you place the default value of the #IMPLIED attribute, you havr to place it in you application that will process the instance. However you might also have something like that in your DTD

   status (draft|final|other) #IMPLIED
   audience (novice|expert) #REQUIRED

if you do not supply the value for your status attribute, it is understood by the parser that your application will use some predefined default value for this attribute. If you ommit your audience attribute however, the parser is going to complain that the instance is not valid, since it is required that this attribute have to be present in the instance


Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question