xerces-p-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Harper" <pa...@ncube.com>
Subject Question on using ENTITY's in attribute values when creating DOM elements
Date Tue, 30 Nov 2004 23:11:35 GMT

I'm using Xercesp 2.3.0-1 and am creating a DOMDocument with the following
code (similar to some of the sample code in the distribution):

    $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');
    $dt   = $impl->createDocumentType($PrimaryTagName, '', $DTDURL);
    $doc  = $impl->createDocument('', $PrimaryTagName, $dt);

This has been working well, but when I added an ENTITY to my DTD that I wanted to
use in an attribute value created with code, I hit a snag.  The ENTITY is:

<!ENTITY ver "1.0">

and I wanted to be able to set an attribute as:

    $v = $doc->createElement("VersionElem");
    $v->setAttribute('version' , '&ver;');

What this produced when serialized was:

  <VersionElem version="&amp;ver;"/>

Not what I had hoped for.

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.'

The documentation for Xerces 2.6 reads the same way.

So, is there another way to insert ENTITY references in attribute values or am I stuck until
XercesC is updated?

Thanks in advance,

Paul Harper
paulh@ncube.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org


Mime
View raw message