Re: [xml] Entity output query



I've been unable to infer a meaningful answer from the silence
that greeted this question.  Shall I just submit this to the bug
system?

If it helps, I've attached some documents which, when processed
with xsltproc, will demonstrate the issue.

broken.xsl results in the raw 8-bit character; works.xsl
generates the XML entity.

-John


At (time_t)756596365 "John R. Daily" wrote:

In xmlEncodeEntitiesReentrant() in entities.c, the following
logic appears at line 481 (as of version 2.6.0):

      } else if (*cur >= 0x80) {
          if (((doc != NULL) && (doc->encoding != NULL)) || (html)) {
                /* Simply copy the character */
            } else {
                /* Translate into an entity */
            }

The decision of whether to copy an 8-bit character or turn it
into an entity seems to be:

  If we have an encoding for the output, or if we are generating
  HTML, don't construct an entity.

Thus the probability of turning an 8-bit character into an entity
would seem to be very low.

This strikes me as a rather strange way to make the decision;
when I'm converting to HTML, I'd much rather have the entity than
the raw character.  In fact, the else clause knows how to
generate HTML entities, but will never do so.


I don't know what the "right" logic is; I'm definitely curious
under what circumstances it is desirable to _not_ generate
entities in XML/HTML output.

--
John R. Daily                                        jdaily progeny com
Director of Technology                            Progeny Linux Systems
                    Master of the ephemeral epiphany
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml


<sometext>
  This is a copyright symbol: &#169;
</sometext>
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method="html" encoding="iso-8859-1"
  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; />
  
<xsl:template match="/">
  <html><body><xsl:apply-templates/></body></html>
</xsl:template>

</xsl:stylesheet> 
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output method="xml"
  doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"; />
  
<xsl:template match="/">
  <html><body><xsl:apply-templates/></body></html>
</xsl:template>

</xsl:stylesheet> 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]