470,841 Members | 883 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,841 developers. It's quick & easy.

Help for parsing Internal ENTITY & Co

Max
I am writing a XML parser in Javascript and i have difficulty to understand
the specifics of some "entities". I would want to understand the way in
which the non-validating XML Parsers manage entities (ENTITY) in XML
documents.
In practical i don't understand if XML Parsers manage the values of Internal
Entities (<!ENTITY entityname "replacement text">), if they manage the
Parametric Entities and if the Entity Reference is only a Node or it is
linked to other Entities (Internal Entities).
I have given a look to many parser, written in many languages, but they make
more non-standard operations on the Internal Entity :-/
Can anyone help me?

Max
May 14 '06 #1
4 1208
The answer is "It depends".

Parsed entities may simply be expanded during parsing, in which case you
see only their replacement value as if that had been typed directly into
the file.

Or they may be separated out -- in the DOM, that's done by enclosing the
replacement value in an EntityReference node; SAX surrounds the
replacement value with calls to the LexicalHandler methods startEntity
and endEntity.

Which happens depends on which parser you're using, how you've
configured it, and what DOM implementation or SAX listeners these are
feeding.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
May 14 '06 #2
Max
> The answer is "It depends".

Parsed entities may simply be expanded during parsing, in which case you
see only their replacement value as if that had been typed directly into
the file.
Thanks for the response, Joe.

In practical, you think that the XML Parsers expands the entity references
while traversing the tree:

ex. in the internal DTD:
<!ENTITY name "Jerry">

XML file:

<hello>
<Cherries>&name;</Cherries>
</hello> Results:
<hello>
<Cherries>Jerry</Cherries>
</hello>
Or they may be separated out -- in the DOM, that's done by enclosing the
replacement value in an EntityReference node; SAX surrounds the
replacement value with calls to the LexicalHandler methods startEntity
and endEntity.
In this case, is the replacement value enclosed in the nodeValue of
EntityReference Node (inherited by superclass Node) or in the nodeValue of
Entity Node or other?
Which happens depends on which parser you're using, how you've
configured it, and what DOM implementation or SAX listeners these are
feeding.


I'm writing a personal XML Parser.

All the best,

Max
May 15 '06 #3
>>Or they may be separated out -- in the DOM, that's done by enclosing the
replacement value in an EntityReference node
In this case, is the replacement value enclosed in the nodeValue of
EntityReference Node (inherited by superclass Node) or in the nodeValue of
Entity Node or other?


Children of the EntityReference node. See the DOM spec for details.
I'm writing a personal XML Parser.


If you really insist on doing this, I recommend you start by reading the
Annotated XML Specification website with extreme attention to every word
of the spec and of Tim Bray's commentary upon it. That'll save you from
having to repeat some of the mistakes everyone else has already made and
corrected.

Have fun.
May 15 '06 #4
Max
> > In this case, is the replacement value enclosed in the nodeValue of
EntityReference Node (inherited by superclass Node) or in the nodeValue of Entity Node or other?
Children of the EntityReference node. See the DOM spec for details.


During the parsing, i have to "map" the internal Entities and to add a
children node of matched type of internal value to EntityReference. If the
internal value is a element or another EntityReference, i have to re-parse
or re-expand it.
Is it correct?
If you really insist on doing this, I recommend you start by reading the
Annotated XML Specification website with extreme attention to every word
of the spec and of Tim Bray's commentary upon it. That'll save you from
having to repeat some of the mistakes everyone else has already made and
corrected.


Thanks for the suggests!

Max
May 16 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by qazmlp | last post: by
2 posts views Thread by Christoph Niemann | last post: by
1 post views Thread by Razvan | last post: by
6 posts views Thread by Tuomas Rannikko | last post: by
3 posts views Thread by Moqtar | last post: by
reply views Thread by bruce | last post: by
2 posts views Thread by embz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.