well formed attributes: no < ?

A

Armel Asselin

Hello,

I've been using XML for a while in a rather 'free' manner (i.e. as long as
IE accept it it's OK), I read recently (again) the Xml standard 1.0 (3rd
edition) and found this sentence:

Well-formedness constraint: No < in Attribute Values
The replacement text of any entity referred to directly or indirectly in an
attribute value MUST NOT contain a <.

it's seems to imply that:
<tag attr="&lt;" />
is not good XML. but for example the doc of XSL shows numerous samples where
&lt; is used in attributes. is the XSL doc wrong? or is this well-formedness
rule obsolete? or not enforced by anybody? or is this something else?

Regards
Armel
 
R

Richard Tobin

Armel Asselin said:
Well-formedness constraint: No < in Attribute Values
The replacement text of any entity referred to directly or indirectly in an
attribute value MUST NOT contain a <.

it's seems to imply that:
<tag attr="&lt;" />
is not good XML. but for example the doc of XSL shows numerous samples where
&lt; is used in attributes. is the XSL doc wrong? or is this well-formedness
rule obsolete? or not enforced by anybody? or is this something else?

You have misunderstood the rule. It means that
<tag attr="<" />
is illegal.

The replacement text of the entity reference in
<tag attr="&lt;" />
is
<
(or something similar) which does not contain a < character.

-- Richard
 
A

Armel Asselin

Richard Tobin said:
You have misunderstood the rule. It means that
<tag attr="<" />
is illegal. ok... :)
The replacement text of the entity reference in
<tag attr="&lt;" />
is
<
(or something similar) which does not contain a < character.
this is the 'double encoding' stuff in definitions so...

thank you very much
Armel
 
M

Malcolm Dew-Jones

Armel Asselin ([email protected]) wrote:
: Hello,

: I've been using XML for a while in a rather 'free' manner (i.e. as long as
: IE accept it it's OK), I read recently (again) the Xml standard 1.0 (3rd
: edition) and found this sentence:

: Well-formedness constraint: No < in Attribute Values
: The replacement text of any entity referred to directly or indirectly in an
: attribute value MUST NOT contain a <.

: it's seems to imply that:
: <tag attr="&lt;" />
: is not good XML.

I think the standard means no _unescaped_ < should ever appear.

You can put anything you wish in the value as long as it is correctly
escaped.
 
J

Joe Kesselman

Malcolm said:
You can put anything you wish in the value as long as it is correctly
escaped.

Almost. In XML 1.0, characters that weren't in the official XML
character set weren't permitted even as numeric character references; to
represent them you had to translate them using some other representation
such as base-64 encoding or your own custom escaping mechanism. I seem
to remember that 1.1 relaxed that, but I may be misremembering.
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,833
Latest member
BettyeMacf

Latest Threads

Top