Christopher Knorr wrote:
> I have no DTD and I parse an attribute on an element. Is that attribute
> assumed to by of type CDATA?
If there is no declaration information, the parser has no way
of knowing how to normalize attribute values. Therefore, all
attributes will be of type CDATA.
> If it is of type CDATA, do the attribute normalization rules apply?
There are really no normalization rules for CDATA in the same
sense that the other attribute types are normalized. For
example, whitespace is not trimmed. Refer to Section 3.3.3[1]
of the XML 1.0 (SE) specification for precise details.
> Would the attribute name="<<<here>>>" parse ok if it is considered CDATA by
> default?
No, because you're not allowed to have a bare '<' character
in your attribute value. It doesn't matter what the type of
the attribute is, you have to escape it using "<".
> Will all parsers handle it this way?
I don't know. Are we talking about all *conforming* parsers?
> What if I declare xml:space="preserve" on my root element, will that effect
> the attribute normalization on sub elements? Or just the content data?
The "xml:space" attribute in NO WAY affects the normalization
or other processing of attributes or element content. It is
merely a hint to the application on how *it* should deal with
character content. Normally this attribute refers to the
element's content, not its attributes.
IMHO, this attribute should be declared for all elements you
want it to apply. In other words, it does not apply to the
children elements. My opinion is different from the writers
of the W3C Canonical XML spec, however. In section 2.4[2] of
that spec, they mention how canonicalizing document subsets
will gain any "xml:lang" and "xml:space" attributes appearing
along the ancestor axis. I don't like this because it means
that you are modifying the document's information set.
> Is this legal for an attribute name="![CDATA[ <<<here>>>]]"
No. Again, for the same reason as before. You can't have a
bare '<' character in your attribute value. And you're not
allowed to use CDATA sections within attribute values.
Read the XML specification for exactly what you are allowed
and not allowed to do in an XML document.
References:
[1] http://www.w3.org/TR/2000/REC-xml-20001006#AVNormalize
[2] http://www.w3.org/TR/2001/REC-xml-c14n-20010315#DocSubsets
--
Andy Clark * IBM, TRL - Japan * [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]