xsl-list
[Top] [All Lists]

Re: character entity references; saxon ie 6.0 differences

2003-08-26 11:10:42
Dan,

At 12:59 PM 8/26/2003, you wrote:
I have the following XML fragment:

<RECORDITEM sqlsource="cityprov" colname="col4">Montr&eacute;al,
QC<RECORDREF>specialannual</RECORDREF></RECORDITEM>

I want my output to be:

<td>Montr&eacute;al</td><td>specialannual</td>
My xsl is:
        <xsl:for-each select="RECORDITEM">
          <td align="right">
            <font face="verdana" size="1">
            <xsl:value-of select="text()"/>
            </font>
          </td>
          <td align="right">
            <font face="verdana" size="1">
            <xsl:value-of select="RECORDREF"/>
            </font>
          </td>
        </xsl:for-each>
When I use ie 6.0 to open this the entity "&eacute;" is not interpreted as
text? so I get something like the following:
<td align="right>Montr</td><td align="right">specialannual</td>
When I translate it with saxon everything comes out as I want.
Which is correct and can I write my XSL to overcome the discrepancy?

Saxon is correct, at least if you interpret the spec strictly as to what constitutes a text node.

For some reason, IE is splitting the text node into pieces around the entity reference, so when you say select="text()" it's only giving you the piece before the entity appeared.

There may be a setting you can switch when you invoke it to make it behave in closer conformance with XPath's expectations, not whatever DOM it's using that discriminates those entity references.

This can't be fixed straight from the stylesheet, but if you can tweak your XML source to be something a bit more robust, such as

<RECORDITEM sqlsource="cityprov" colname="col4">
  <VALUE>Montr&eacute;al, QC</VALUE>
  <RECORDREF>specialannual</RECORDREF>
</RECORDITEM>

then it'd be easy to write stronger XSLT that would fix this (MSXML should report the value of VALUE properly irrespective of the entity reference).

Cheers,
Wendell


======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


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



<Prev in Thread] Current Thread [Next in Thread>