You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Hal DeVore <ha...@acm.org> on 2000/10/21 20:07:55 UTC

Entity-reference in attributes

The description of the "Attr" Interface in the "Document Object
Model (Core) Level 1" spec says this:
   "... the child nodes of the Attr node provide a representation
   in which entity references are not expanded".

I'm probably doing something wrong but I can't seem to get the
DOMParser to leave entity references unexpanded in attributes
in spite of having done setCreateEntityReferenceNodes(true).

If I have an entity like this:

  <!ENTITY version "1.0.3.4">

and I have XML that looks like this:

<MYDOCUMENT VERSION="&version;">
&version;
</MYDOCUMENT>

I find an ENTITY_REFERENCE node as one of the children of the
MYDOCUMENT ELEMENT node.  That ENTITY_REFERENCE has a name of
"version" and a TEXT_NODE child with the expansion of the
"version" entity.

I also can get the attribute using the getAttributes(),
but the VERSION attribute node has only a single child of type
TEXT_NODE containing the expanded entity.

I'm sure I'm missing something because I'm just getting started
with Xerces.  I'm using the xerces-c1_3_0-win32.zip precompiled
binary from the stable directory.  I've gone thru the last 3
months of the mailing list archives and read everything on
entities.  Nobody mentioned using entities in attributes.

Help.

--Hal



Re: Entity-reference in attributes

Posted by Hal DeVore <ha...@acm.org>.
>>>>> On Sat, 21 Oct 2000, "Dean" == Dean Roddey wrote:

  Dean> The reason is that the underlying scanner doesn't support
  Dean> this. I never forsaw this requirement when I wrote that
  Dean> code, so it might require a good bit of examination to
  Dean> make sure that the correct modifications are made to
  Dean> support it. So anyway, there's no way the DOM can do this
  Dean> until the underlying scanner is updated to handle it.

Thanks.  That would explain it.

Any plans to do this?  Alternatively, are you aware of any C
or C++ parsers that support this?  I'm writing a program that
manipulates XML documents in specific ways for a project I'm
on and I need the ability to retain the entity references as
references even when they appear in attributes.

I'd be willing to tackle this myself but the learning curve for
me to become a useful contributor to Xerces-C would probably be
longer than I have to get this project handled.

--Hal



Re: Entity-reference in attributes

Posted by Dean Roddey <dr...@charmedquark.com>.
The reason is that the underlying scanner doesn't support this. I never
forsaw this requirement when I wrote that code, so it might require a good
bit of examination to make sure that the correct modifications are made to
support it. So anyway, there's no way the DOM can do this until the
underlying scanner is updated to handle it.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"It takes two buttocks to make friction"
    - African Proverb


----- Original Message -----
From: "Hal DeVore" <ha...@acm.org>
To: "xerces-c" <xe...@xml.apache.org>
Sent: Saturday, October 21, 2000 11:07 AM
Subject: Entity-reference in attributes


> The description of the "Attr" Interface in the "Document Object
> Model (Core) Level 1" spec says this:
>    "... the child nodes of the Attr node provide a representation
>    in which entity references are not expanded".
>
> I'm probably doing something wrong but I can't seem to get the
> DOMParser to leave entity references unexpanded in attributes
> in spite of having done setCreateEntityReferenceNodes(true).
>
> If I have an entity like this:
>
>   <!ENTITY version "1.0.3.4">
>
> and I have XML that looks like this:
>
> <MYDOCUMENT VERSION="&version;">
> &version;
> </MYDOCUMENT>
>
> I find an ENTITY_REFERENCE node as one of the children of the
> MYDOCUMENT ELEMENT node.  That ENTITY_REFERENCE has a name of
> "version" and a TEXT_NODE child with the expansion of the
> "version" entity.
>
> I also can get the attribute using the getAttributes(),
> but the VERSION attribute node has only a single child of type
> TEXT_NODE containing the expanded entity.
>
> I'm sure I'm missing something because I'm just getting started
> with Xerces.  I'm using the xerces-c1_3_0-win32.zip precompiled
> binary from the stable directory.  I've gone thru the last 3
> months of the mailing list archives and read everything on
> entities.  Nobody mentioned using entities in attributes.
>
> Help.
>
> --Hal
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>