Hi,

Tobias Reif <tobiasreif / pinkjuice.com> wrote:
> > In XML 1.0 Rec., there are 5 predefined general entities: "&", "<", ">",
> > "'" and '"'.
> > (cf. 4.6 Predefined Entity
> >      http://www.w3.org/TR/REC-xml#sec-predefined-ent )
> > 
> > Should REXML convert "'" and '"' into &apos; and &quot;?
> 
> 
> AFAICS: no.
> write
> foo.attributes["bar"] = "aaa&apos;bbb&quot;ccc"

uuuum...Do you really want to write Ruby scripts in such a style?

Even in DOM 1.0 Rec., Element#setAttribute's value is literal text,
not escaped.

(http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-F68F082)

  This value is a simple string, it is not parsed as it is being
  set. So any markup (such as syntax to be recognized as an entity
  reference) is treated as literal text, and needs to be appropriately
  escaped by the implementation when it is written out. In order to assign
  an attribute value that contains entity references, the user must create
  an Attr node plus any Text and EntityReference nodes, build
  the appropriate subtree, and use setAttributeNode to assign it
  as the value of an attribute.

Of cource, if "'" is in XML source file as attribute's value
quoted "'", REXML parser should raise error, as you say.


Regards,

TAKAHASHI Masayoshi (maki / inac.co.jp)