#FIXED DTD attribute

J

Joe Kesselman

Soren said:
If I declare an attribute #FIXED as in
<!ATTLIST gedefims a1 CDATA #FIXED "fis">
Does the attribute HAVE to be present in instance docuements

Essentially, #FIXED implies #DEFAULT. If you don't specify it this value
will be provided automatically; if you do, you must specify the same value.

(From the spec: "If the declaration is neither #REQUIRED nor #IMPLIED,
then the AttValue value contains the declared default value; the #FIXED
keyword states that the attribute must always have the default value.")
 
P

Peter Flynn

Soren said:
Hi,

If I declare an attribute #FIXED as in

<!ATTLIST gedefims a1 CDATA #FIXED "fis">

Does the attribute HAVE to be present in instance docuements, as with
#REQUIRED? As I read the XML spec, I can't find where that is said; only
that the value of the "a1" attribute must be "fis" if present.

On the other hand, some people use #FIXED to "enforce" presence of
namespace bindings. Without the required semantics, what is enforced?

FIXED means that after validation, the attribute value will be present
in the tree, whether or not it was explicitly given in the document.
So, for example, you can refer in XSLT to "@a1" and it will always be
"fis". It can indeed be treated as a way of passing fixed information
through from the DTD to the parsed instance.

///Peter
 
R

Richard Tobin

Soren Kuula said:
<!ATTLIST gedefims a1 CDATA #FIXED "fis">

Does the attribute HAVE to be present in instance docuements, as with
#REQUIRED? As I read the XML spec, I can't find where that is said; only
that the value of the "a1" attribute must be "fis" if present.

If the attribute is present in the instance, it must be "fis".
If it isn't, then it defaults to "fis" anyway.

If (perversely) you want to allow only one value, but require it
to be present, you can do this provided the value is a name token:

<!ATTLIST gedefims a1 (fis) #REQUIRED>

-- Richard
 
S

Soren Kuula

Hi,

If I declare an attribute #FIXED as in

<!ATTLIST gedefims a1 CDATA #FIXED "fis">

Does the attribute HAVE to be present in instance docuements, as with
#REQUIRED? As I read the XML spec, I can't find where that is said; only
that the value of the "a1" attribute must be "fis" if present.

On the other hand, some people use #FIXED to "enforce" presence of
namespace bindings. Without the required semantics, what is enforced?

Soren
 
R

Richard Light

Peter Flynn said:
FIXED means that after validation, the attribute value will be present
in the tree, whether or not it was explicitly given in the document.
So, for example, you can refer in XSLT to "@a1" and it will always be
"fis". It can indeed be treated as a way of passing fixed information
through from the DTD to the parsed instance.

However, if you're talking about enforcing namespace bindings, and
you're using MSXML as your parser, this doesn't appear to be the case.
I have just been battling with this issue myself, while trying to
produce an XTM 2.0 document which conforms to the DTD.

Without an explicit instance of the xmlns attribute in the document
(matching the #FIXED value), you get the error message:

Use of default namespace declaration attribute in DTD not supported.

This doesn't appear to be a new or unknown problem. A Google search
brought up this posting from Aung Aung (a Microsoft employee, I think),
dated 3 Jan 2001:

"Well, clearly it is a bug on msxml according to the spec. I am pushing
a fix for this.

Workaround : msxml will need the namespace explicitly specified in the
document.
e.g according to the spec if you defined the default namespace in the
DTD, one should not need to put it on the <doc> node."

The "fix" has clearly not been forthcoming ...

Richard Light
 
J

Joe Kesselman

Richard said:
However, if you're talking about enforcing namespace bindings, and
you're using MSXML as your parser, this doesn't appear to be the case. I
have just been battling with this issue myself, while trying to produce
an XTM 2.0 document which conforms to the DTD.

If you're working with namespaces, you probably should move from DTDs to
schemas at you soonest possible opportunity. Namespaces and DTDs really
don't play very nicely with each other, since they have conflicting
ideas of what's meaningful in an XML document.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top