Skip to main content
July 4, 2018
Question

Attributes (Default values)

  • July 4, 2018
  • 2 replies
  • 1262 views

Optional attributes may have default values, required attributes may not. Why not?

This topic has been closed for replies.

2 replies

Legend
July 6, 2018

But for a moment back to the original question:

An attribute like “id” might be required for an element must must not have a default value for obvious reasons (as an ID usualy has to be unique).

July 7, 2018

Here is an example of a simple list:

Two attributes are given:

  • Type: Ordered/Unordered for numbers/bullets
  • StartWith1: True/False for the first entry/following entries

At the moment, both attributes are marked as optional.

But both attributes are required. And in the daily work default values are very helpful.

Therefore, elements with required attributes and default values would be on my wishlist.

Ian Proudfoot
Legend
July 7, 2018

Back in 1994 when I first discovered the delights of SGML, I too was puzzled by this rule, but eventually its reasoning became very clear. There really is a definite logical consistency with the idea that a required attribute cannot have a default value. The reason is that it's a requirement for the user to make a choice regarding the content of the attribute. By its very definition it cannot be a defaulted value because that means no choice has been made. It seems that the original question could be restated as "Why can't we have an attribute be required but also optional?"

I think it would be a real error to go down that path. This is really a fundamental SGML/XML rule that FrameMaker should stick with. Imagine how complex life would become if there was such a fundamental difference between XML and FrameMaker... (Yes there are already too many ).

Lothar:

Is your simple list example a real document? I've can't remember seeing the list type defined at the list item level before, it means that it must be defined for each new list entry. Wouldn't it be better placed on the <List> element?

Why would the 'StartWith1' attribute benefit from being required? The majority of the entries in a list will be 'False'. So if anything it should be an Optional attribute with a default of 'False'. Take the argument a little further and it would be easy to state that depending on the structure model, there would be no need for a 'StartAt1' attribute as it can be inferred from the structure.

Ian

Legend
July 5, 2018

That is a good question! What an excellent feature that would be! I have had many, many use cases for this functionality and in fact, it was one of the original driving forces behind my Structure Tools plugin:

WS Structure Tools - West Street Consulting

This plugin provides a wide array of default and auto-populate options. But I am not sure why a plugin is required... seems like it would be a simple thing to provide basic default value functionality within the core product.

Russ

Inspiring
July 6, 2018

Sorry, Russ, but I disagree. If there is a default value, the user is not required to specify a value. Thus, an attribute with a default value cannot be required, just by the definition of the English word "required".

It certainly may happen that some users (for example, those at a particular organization) of a widely-used tagging scheme may prefer to have a default for an attribute that is required by the broader tagging scheme. In such cases, the EDD can define a default and XSLT can fill in that value when switching between FrameMaker and XML.

     --Lynne