You are viewing a plain text version of this content. The canonical link for it is here.
Posted to p-dev@xerces.apache.org by Paul Harper <pa...@ncube.com> on 2004/12/01 00:11:35 UTC
Question on using ENTITY's in attribute values when creating DOM elements
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="&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
Re: Question on using ENTITY's in attribute values when creating
DOM elements
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Paul Harper" <pa...@ncube.com> writes:
> $v = $doc->createElement("VersionElem");
> $v->setAttribute('version' , '&ver;');
>
> What this produced when serialized was:
>
> <VersionElem version="&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.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org