"James Britt (rubydev)" <james / rubyxml.com> wrote:
> Quote characters are fine, so long as there is no ambiguity when used inside an attribute value.
>  <foo bar='Ain't it cool!' /> # Evil
> 
> This is mal-formed because that second apostrophe indicates the end of the attribute value. Then comes some more text that doesn't
> parse well.
>   <foo bar="Ain't it cool!" />  # OK
> 
> Changing the quote style works, but you may not always know, or control, how an XML builder will quote your attribute data.  So, you
> have to watch for this, too:
>   <foo bar="Give me an "A"!" />  # Ow!

In addition, when we use them as text, it's no problem.

<foo>
  <bar>Ain't it cool!</bar>
  <bar>Give me an "A"!</bar>
</foo>

> It's not the characters themselves that are a problem, it's the context.

I think so too.

> Having REXML automagicaly convert these to their entity references helps avoid these sorts of conflicts.

We have some options.

a) "'" and '"' are automatically converted entity reference always.
b) "'" and '"' are converted if it's attribute's value.
c) Attribute object has @quote_mark variable which character use
   in serializing, and "'" and '"' are converted when @quote_mark
   uses same character.
d) XMLWriter object has @quote_mark variable which character use
   in writing, and "'" and '"' are converted when @quote_mark
   uses same character.


Regards,

TAKAHASHI Masayoshi (maki / inac.co.jp)