Go Back   Velocity Reviews > Newsgroups > XML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

XML - Help for parsing Internal ENTITY & Co

 
Thread Tools Search this Thread
Old 05-14-2006, 11:57 PM   #1
Default Help for parsing Internal ENTITY & Co


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




Max
  Reply With Quote
Old 05-15-2006, 12:24 AM   #2
Joe Kesselman
 
Posts: n/a
Default Re: Help for parsing Internal ENTITY & Co

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
  Reply With Quote
Old 05-15-2006, 03:09 PM   #3
Max
 
Posts: n/a
Default Re: Help for parsing Internal ENTITY & Co

> 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


  Reply With Quote
Old 05-15-2006, 04:04 PM   #4
Joe Kesselman
 
Posts: n/a
Default Re: Help for parsing Internal ENTITY & Co

>>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.
  Reply With Quote
Old 05-16-2006, 07:50 PM   #5
Max
 
Posts: n/a
Default Re: Help for parsing Internal ENTITY & Co

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


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump