Re: Question on using ENTITY's in attribute values when creating DOM elements

[email protected] (Jason E. Stewart) Wed, 01 Dec 2004 14:47:01 +0530
Newsgroups gmane.text.xml.xerces-p.devel
Message-ID <[email protected]>
"Paul Harper" <[email protected]> writes:

>     $v = $doc->createElement("VersionElem");
>     $v->setAttribute('version' , '&ver;');
>
> What this produced when serialized was:
>
>   <VersionElem version="&amp;ver;"/>
>
> Not what I had hoped for.

Ugh, yuck.

> I believe that I found the root of the problem in the documentation on the createDocumentType method:
>
>     'Entity declarations and notations are not made available. Entity reference
>     expansions and default attribute additions do not occur. It is expected 
>     that a future version of the DOM will provide a way for populating a 
>     DOMDocumentType.'

I think this is a red herring. I think the real culprit is the "expand
entitry references" flag. You can use the setExpandEntityReferences()
method on any parser (DOM or SAX) try setting it to false and see what
happens.

I must admit that I haven't ever tried this.

Cheers,
jas.