[xsl] Unanticipated Results from text()

Subject: [xsl] Unanticipated Results from text()
From: "Signature House" <systems@xxxxxxxxxxxxxxxxxx>
Date: Fri, 23 Feb 2007 12:34:44 -0500
Hi

I'm working on a project involving an XML import into the FileMaker DB package. I'm using Internet Explorer to do quickie proofing
on my stylesheets before using them in FM since FM is a bit of a kludge.

I got one bit working the way I wanted in IE, but got a different result when I moved it into FM.

Using the IE STYLESHEET and XML INPUT 1 below, I got IE RESULTS FROM BOTH INPUTS vs FM RESULTS FROM INPUT 1. The
"normalize-space(text())" picked up the B2 text in IE but didn't in FM.

I ran about a dozen different versions of the XML input, removing 1 or more line breaks from different places. IE always picked up
the B2 text; sometimes FM did, sometimes it didn't (see at FM RESULTS FROM INPUT 2 for one where FM did work).

Empirically, if <BBB><CCC> were on the same line, IE & FM returned the same results; if <BBB><CCC> were on separate lines, the
results were different.

I'm working on a PC running XP SP2, IE 6 SP2 and FM 8.03. FM says they're using an Xerces-based XML parser and an Xalan-based XSLT
processor (Xerces-C 1.6.0, Xalan-C 1.3.0). My stylesheets use the same XSLT, but for FM I have to remove the HTML and add a bunch of
required metadata. It's longish so I didn't include it but I can if someone needs to see it. The line breaks are the standard
Windows hex 0D 0A pair.

Does anybody have any suggestions as to what is going on?
- Is the placement of the B2 text valid XML?
- Is this a difference between IE & Xalan?
- What results should I expect - B2 or not B2? (Gee, I should have used 2B as the sample!)

Thanks in advance

Mike McBee
Signature House
systems@xxxxxxxxxxxxxxxxxx
www.signaturehouse.net
304-842-3386


IE STYLESHEET
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="List Nodes - HTML.xsl"?>
<xsl:template match="/">
  <table>
    <tr><td>Name</td><td>Text</td><td>Period</td></tr>
    <xsl:for-each select="//*">
      <tr>
        <td><xsl:value-of select="name(.)"/></td>
        <td><xsl:value-of select="normalize-space(text())"/></td>
        <td><xsl:value-of select="normalize-space(.)"/></td>
    </tr>
    </xsl:for-each>
  </table>
</xsl:template>


XML INPUT 1
<?xml version="1.0"?>
<?xml-stylesheet?>
<AAA>
<BBB>
<CCC>
C1
</CCC>
B2
</BBB>
</AAA>


XML INPUT 2
<?xml version="1.0"?>
<?xml-stylesheet?>
<AAA><BBB><CCC>C1</CCC>B2</BBB></AAA>


IE RESULTS FROM BOTH INPUTS
Name  Text  Period
AAA         C1 B2
BBB   B2    C1 B2
CCC   C1    C1


FM RESULTS FROM INPUT 1
Name  Text  Period
AAA         C1 B2
BBB         C1 B2
CCC   C1    C1


FM RESULTS FROM INPUT 2
Name  Text  Period
AAA         C1 B2
BBB   B2    C1 B2
CCC   C1    C1

Current Thread