[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: XML parsers and entity references (was RE: Using Entity Refer ence s in XSL Templates)


Subject: RE: XML parsers and entity references (was RE: Using Entity Refer ence s in XSL Templates)
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 24 Jan 2000 09:47:20 -0000

> I'm not that familiar with what parsers do, but I was under 
> the impression that a SAX based parser simply reports in a consistent
manner 
> "hey I found the beginning of an element 'foo'" and "hey I found an entity

> reference 'nbsp' which refers to the UCS character 160" and so on, and 
> it was up to the application using that information to decide whether or 
> not to preserve info about the entity references or their expanded values.


A SAX parser reports data to the registered DocumentHandler after resolving
entity references, so the DocumentHandler never gets to know whether the
text comes from the main document or from an entity that it references.

You also have the option of registering an EntityResolver which is called
when an external entity is referred to, the purpose of this is to allow you
application to locate the entity being referred to (e.g. it might be in a
database somewhere). This allows you, if you wish, to treat data in an
external entity differently from data in the main document, but you have to
work hard to achieve this.

Character references such as &#160; and internal entity references (IIRC)
are not notified to the application at all, the application just gets to see
the expanded text.

Mike Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread